0
私の指示にボタンを付けてボタン名を取得したいが、指示が機能しない。私は角度が新しく、問題がどこにあるのか把握できません。私のコードを見て、理由を教えてください。AngularJS:指示ボタンからクリックしてボタンのID名を取得
var app = angular.module("myApp", []);
app.directive('busybox',function(){
return function(scope, element, attrs){
element.click(function(){
//element.parent().find('.main').append('<div>Some text</div>')
alert('hello');
})
}
})
jsfiddle https://jsfiddle.net/tridip/4o1zkbj1/1/
作業
element.on('click', function(\\
を使用しますが、私は、オブジェクトを返す必要があるが、あなたが話しているオブジェクトと?そのリンク機能です。関数はどのようにオブジェクトとして使用できますか? –
@Tridip:ディレクティブ関数はオブジェクトを返し、 'link'はそれの関数プロパティです。 [Docを読む](https://docs.angularjs.org/guide/directive#creating-directives) – anoop