私はそれは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); '単にオブジェクトが文字列として出てくるのか、それとも他のデータ型であるのかを調べるだけです。 –