AngularJSディレクティブがパラメータとして渡された属性を評価する良い方法はありますか?ディレクティブの属性値を評価するにはどうすればよいですか?
link: function postLink(scope, element, attrs) {
debugger; // scope.$parent already knows the value of teacher here
scope.sendEmail = function(){
alert(attrs.recipient);
//window.open("mailto:" + attrs.recipient);
}
}
私はteacher.email
の値を使用するための指示をしたいと思います(リンク機能を持っていることに注意してください:ここでは
は(私はあなたが指示なしにこの動作を実装することができ認識)私の問題を示すことsimplified exampleです文字列teacher.email
ではなく、scope.$parent.teacher
の正しい値)。
attrs.recipientをscope.recipientに置き換えてください。 –