logo
down
shadow

Cannot read property 'then' of undefined in angularjs


Cannot read property 'then' of undefined in angularjs

Content Index :

Cannot read property 'then' of undefined in angularjs
Tag : angularjs , By : krs
Date : December 05 2020, 12:23 PM

it helps some times i was trying to make a simple app in ionic with asp.net mvc rest framework.but am getting , You are already returning a promise in your below function.
var getApiData = function() {
    $http.get(ApiEndpoint.url + '/product')
        .success(function(data) {

        })
        .error(function(error) {
        })
 }
var getApiData = function() {
    return $http.get(ApiEndpoint.url + '/product')
}

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

AngularJS Cannot read property 'otherwise' of undefined


Tag : javascript , By : Kuer
Date : March 29 2020, 07:55 AM
This might help you Your injector array is missing the $urlRouterProvider. All dependencies must be listed there.
app.config(["$stateProvider", "$urlRouterProvider",
    function ($stateProvider, $urlRouterProvider) {
      ...
}]);

AngularJS 2 - inner property data binding - EXCEPTION: TypeError: Cannot read property of undefined in


Tag : javascript , By : Denis Chaykovskiy
Date : March 29 2020, 07:55 AM
I hope this helps you . After some research, I found out that the problem was due to the fact that component template (HTML) was rendered even before the JSON data was available to the corresponding component.
The following post was helpful to determine the cause. Angular2: How to load data before rendering the component?
@Component({
templateUrl: 'app/approver/approver_approvebooking.html'
})

export class ApproveCabBookingComponent implements OnInit {
private errorMessage: string;
private approveBooking: ApproveBooking;
private isDataAvailable: boolean;

constructor(
    private _logger: Logger,
    private _router: Router,
    private _routeParams: RouteParams,
    private _cabBookingService: CabBookingService) { 

    this.isDataAvailable = false;
}

ngOnInit() {
    let bookingId = this._routeParams.get('bookingId');
    this._logger.log("bookingId inside ngInit = " + bookingId);

    this.approveBooking = this._cabBookingService.getSingleCabBookingForApproval(bookingId)
        .subscribe(
            approveBooking => {
                this.approveBooking = approveBooking;
                this.isDataAvailable = true;
                this._logger.log("this.approveBooking => " + JSON.stringify(this.approveBooking));
            },
            err => {
                this._logger.log("Error while accessing approveBooking...error, JSONed = " + err.status + "," + JSON.stringify(err));
            },
            () => console.log('Approve Cab Booking Entity Fetched!');
            );
}
}
<div *ngIf="isDataAvailable">
    <div class="col-md-12 title-panel">
        <h3>Manage Booking </h3>
    </div>
    <div class="col-md-12 content-panel">
        <form (ngSubmit)="onSubmit()">
            <div class="row">
                <div class="col-md-12">
                    <h4 class="label-heads">Booking ID</h4>
                    <div class="form-value">
                        <span>{{approveBooking.cabBooking.bookingId}}</span>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

angularjs cannot read property then of undefined


Tag : javascript , By : littlefuzz
Date : March 29 2020, 07:55 AM
it fixes the issue I'm trying to return a mongodb collection from my server to the client, but am getting Cannot read property then of undefined on the server-side controller. I get that there is something wrong with the promise but can't seem to solve it. What code changes are needed to fix this? Let me know if more code snippets are needed. , You need to move the return statement outside:
function getAll(){
    console.log('services/course.service  getALL');
    var deferred = Q.defer();

    db.collection('courses').find().toArray(function(err, result) {
        if (err) deferred.reject(err);
        console.log(result);
        deferred.resolve();
    });   

    return deferred.promise;
}

Cannot read property 'then' of undefined AngularJS


Tag : angularjs , By : IanM
Date : March 29 2020, 07:55 AM
To fix this issue As of now your factory getLocation function returns undefined, it's not returning Promise, thus the error is expected. Basically you have misplaced the return def.promise; statement.
GetUserCurrentLocationService.getLocation = function () {
    var def = $q.defer();
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function (position) {
            def.resolve(position);
        });         
    } else {
        //Also reject if navigator.geolocation is undefined
        def.reject({});
    }
    //Function should return promised
    return def.promise;
}

AngularJS testing with Protractor- Cannot read property 'click()' of undefined, even though 'undefined' element has alre


Tag : angularjs , By : Bas
Date : March 29 2020, 07:55 AM
around this issue As already pointed in the comments your then() looks a bit strange. Also you actually don't need it in your case.
Here my suggestion:
it('should navigate to the Charts page', function() {
    console.log("Start Charts page test");
    browser.waitForAngularEnabled(false);
    browser.wait(EC.elementToBeClickable(chartsMenuBtn), 5000);
    //browser.wait(EC.invisibilityOf(blockingElement), 5000);
    chartsMenuBtn.click(); //works, if the element is defined as you said
    browser.wait(EC.urlIs(site + '/#/charts'), 5000);
})
Related Posts Related QUESTIONS :
  • How to pass data from login page to OAuth 2.0 and then get it back?
  • AngularJS routing not working properly in PhoneGap
  • AngularJS: Create new scope variable name using a variable value
  • Directive scope update does not update controller scope (AngularJs)
  • Angular UI Bootstrap4 Vertical Tabs
  • How to show/hide different data on clicking different links in AngularJS?
  • can i paste text input value on-keyup in angular?
  • ui-view do not bind to controler
  • ng-keyup doesn't execute the expression
  • Unit-test a angular controller function in a directive
  • AngularJS - always show two digits after comma
  • Angular View Showing Wrong Result
  • Angular not found until after it's needed?
  • learning angular, having issues with ng-options
  • Angularjs chat with strange polling
  • jQuery Sparkline in a cell in ng-grid using CellTemplate and Directive
  • AngularJS determine filter in controller
  • ADAL tokens not revoking on logout
  • How to deploy an app using ionic framework to Amazon? (elastic beanstalk prefered)
  • Conditional injection of a service in AngularJS
  • Filtering on object properties not working
  • Angularjs: Sorting not working in ui-grid with CellTemplate data
  • How to put serial number for rows in data table according to pagination
  • Play Application Couldn't be Started
  • Video capture to not show in my gallery on phone
  • Reject from 'response' into 'responseError'
  • Angular $injector vs inject
  • how to Avoid ng-repeat in <tr> for particular <td> - Angular Js?
  • Express route handling / req.body empty on some routes
  • AngularJS - Adding controller files triggering uncaught error
  • Using the browser to navigate back in an angularjs app with ui-router?
  • ngResource query, get and save
  • Open $modal from the service and pass variables to the controller
  • ngClick evaluated against scope instead of isolateScope
  • onEnter and onExit are not called when state is left/activated in angularjs ui router
  • Shared client & server modules with angularjs and pongular
  • Getting the angular app to run when using protractor
  • Angularjs: create a link for download different types of file
  • How to mock chained promises using Jasmine?
  • NodeJS on Heroku: Push rejected, failed to compile Node.js app
  • Ionic / Angular JS calling the next page by passing a value into a funciton
  • AngularJS - Passing select list value to function returning undefined
  • Angular JS Material mdMedia seems to be not working
  • directive does not work in the ons-toolbar
  • AngularJS : Pass variables in service
  • AngularJS - FAQ inside a modal (bug?)
  • Is there a way to reduce the number of references declared in jasmine unit tests
  • How to pre-populate and bind list of checkbox using AngularJS
  • angularjs $http.post results in 501 Unsupported method ('POST')
  • AngularJS: On Change of Parent DropDown Option Also Changes the Dependant Drop Down Options Associated with Other Parent
  • Angular HTML5 mode, Wordpress, Rewrites, Apache and You
  • Using angular js form validations in <form:input> tag
  • AngularJS call common functions in a directive template
  • AngularJS Promise resolved incorrectly
  • properly clearing whole AngularJS ui-grid chart
  • Can not figure out how to store $rootScope in angular.bootstrap
  • animate.css animation within angularjs 1.3 using ngAnimate gives different animations in Firefox
  • Auth0 IE Issue: Unable to get property 'frames' of undefined or null reference
  • Am I misusing directives with too much logic?
  • Use an Angular JS value as a parameter of TWIG "path" function in Symfony 2
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com