早上好,我有一個小問題,我有指令:訪問的角度指令範圍內有兩個數據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) –