1
我能夠得到一個基本的組件工作,但試圖加載一些數據通過$ http(users.get()),它返回一個承諾(數據顯示在console.log(this.data)。但該數據不能夠進入組件模板。爲什麼呢?如何在(1.5)角度分量中加載數據?
.component('mrcUserInfo', {
bindings: {
email: '<',
first_name: '<',
last_name: '<'
},
templateUrl: 'components/userInfo.html',
controller: function(users) {
var scope = {};
scope.thisId = 1;
this.miketest = 'this is miketest';
users.get(scope) // basically does a $http()...
.then(function(data) {
this.data = data.data;
this.email = data.email;
this.miketest = 'this is mike 2';
console.log('user?');
console.log(this.data);
});
}
我的模板有這個
this is userInfo.html:
{{ $ctrl.miketest }}
模板顯示「這是miketest」,但它不顯示「這是邁克·2 '
任何線索讚賞。謝謝。Mike
這樣做,謝謝! –