AngularJs $scope doesn't update after a GET request on a factory

前端 未结 5 1001
广开言路
广开言路 2020-12-31 14:10

I have been trying AngularJS for a experimental project and I came along with this problem. In my html I want to display a list of items

Index.html<

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-31 14:45

    Well it looks perfect but you can use $apply like this.

    datModule.controller('datlist', function ($scope, datfactory){
        $scope.$apply(function() {
            $scope.items = datfactory.getlist();
        });
    });
    

提交回复
热议问题