나는 그것이 NG 반복 지시자 내부에 정의되어 자체의 요소 지시어에 정의 된 개체 속성이 정의되지 않은 객체 :각도 지침 속성 속성이
<div ng-repeat="element in array">
<my-directive el-sel="{{element}}>
<something else>
</my-directive>
</div>
을 그리고 이것은 myDirective입니다 :
app.directive('myDirective',function(){
return {
restrict:'E',
scope: false,
link: function($scope,$element,$attrs){
console.log('element:' + JSON.stringify($attrs.elSel));
console.log('href: ' + $attrs.elSel.href);
}
}
});
콘솔 결과는 다음과 같습니다
element:"{\"name\":\"a name\",\"href\":\"#something\"}"
href: undefined
누군가가이 동작하고 뭐를 설명시겠습니까 내가 잘못하고있는거야?
당신이 구문 분석 시도해 봤어':
여기이 지침에 객체를 전달하는 최소한의 예입니다 console.log ($ attrs.elSel);'단순히 객체가 문자열로 올지 또는 다른 데이터 유형으로 오는지 여부를 확인합니다. –