사용자 지정 지시문에서 이상한 동작이 나타납니다. 값을 직접 전달하면 작동하는 것처럼 보이지만 값에 바인딩을 전달하면 작동하지 않습니다. 또한, 내가 console.log 때 올바른 값을 true로 반환하지 않습니다. 비동기 적 데이터가 아직 돌아 오지 않았을 수 있습니다 지시어를 실행 시간, profile.name
할당과지시문 바인딩의 값은 정확하지만 true를 반환하지 않습니다.
//directive
angular.module('tallllyApp')
.directive('userColor', ['simpleLogin', '$timeout', function (simpleLogin, $timeout) {
'use strict';
return {
restrict: 'AE',
scope: {
color: '@'
},
link: function(scope, el, attrs) {
el.css('background', '#5DC472');
console.log(attrs); //attrs.color shows 'Andrey'
console.log(attrs.color); //displays nothing
console.log(attrs.color === 'Andrey'); //false
}
};
}]);
//html = {{profile.name}} does output 'Andrey'
<section class="col user-tasks" user-color color="{{profile.name}}">
정확합니다. 이 비동기 작업을 처리하는 것은 어렵습니다. 특별히 각도에 대한 권장 판독 값은 무엇입니까? – EmptyPockets