This is my template:
<p>{{$ctrl.status}}</p>
This is the component:
var phoneListModule = angular.module("phoneListModule");
phoneListModule.component("phoneList", {
templateUrl: "phone-list/phone-list.template.html",
controller: function PLController($http) {
this.status = "testing";
$http.get("http://localhost/data.json").then(function(response) {
self.status = "again";
});
}
});
And this is the module:
var phoneListModule = angular.module("phoneListModule", []);
The problem is that, the view is compiled properly with the "testing" text, but it's never updated to "again" when the GET request completes.
A console.log confirms that it completed fine
console.log(self.status);
Inside of the then() method.
Why is the view not updating if the dataset has changed?
thisorselfbecause depending where you are ( like inside function or loop ) it means something different. Try withvar vm = this ; vm.status = 'testing'and usevmafter