troubleshooting Question

Angular expressions will not show if $http is called.

Avatar of quest_capital
quest_capital asked on
HTMLAngular.NET Programming
3 Comments3 Solutions128 ViewsLast Modified:
I have a expressions that will not show if $http is called:

Controller
function StaysCtrl($scope, $http, $state, Idle, notify, AuthSrv, appResource) {

    // Will not show up if I make a $http call
    this.helloText = 'Welcome to Stays';

    //appResource.query(function (data) {
    //    $scope.stays = data;
    //});

    // If I comment out this $http call the helloText will show up.
    $http({
        method: 'GET',
        dataType: 'json',
        headers: {
            "Content-Type": "application/json"
        },
        url: 'http://localhost:6060/api/stay/10/desc',
        data: JSON.stringify(),
    }).success(function (data) {
        $scope.stays = data;
    });
    
}

HTML
<div ng-controller="StaysCtrl as stays" class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="text-center m-t-lg">
                <h1>
                    {{stays.helloText}}
                </h1>
                <small>Configure in config.js as minor state.</small>
            </div>
        </div>
    </div>

    <div ng-repeat="stay in stays">
        <div>{{stay.stayID}}</div>
    </div>
</div>

What am I missing?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 3 Answers and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros