We help IT Professionals succeed at work.
Get Started

Angular expressions will not show if $http is called.

127 Views
Last Modified: 2017-11-28
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;
    });
    
}

Open in new window


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>

Open in new window


What am I missing?
Comment
Watch Question
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017
Commented:
This problem has been solved!
Unlock 3 Answers and 3 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE