早上好,我有一个小问题,我有指令:访问的角度指令范围内有两个数据bindigs
return {
restrict:'E',
scope: {
user: "="
},
template: '<b>{{userLogin}}</b>',
link:function(scope,elem,attrs){
},
controller: function ($scope) {
console.log($scope.user)//always undefindet
$scope.userLogin = $scope.user;
},
};
,我想表明我的参数“用户”与范围,模板我必须使用控制器,因为我需要从服务器下载 一些数据,我认为问题是某处这里(指令):
scope: {
user: "=" //when i have this response "undefined"
user: "@" //when i have this response not show id only text
},
我的HTML
<get-user-login user="{{post.user_id}}"></get-user-login>
我总是得到:空值或在控制台中未定义。 如何解决这个问题。
检查'@'和'='之间的区别(http://stackoverflow.com/questions/ 14050195 /什么是在指令范围内的角度js?rq = 1) –