4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ng-clickは複数 置けない

Last updated at Posted at 2016-06-03

###ng-clickは複数配置すると、一番目に記載したものしか実行されません。

例えば下記コードの場合
<button ng-click="hoge()" ng-click="piyo()">
→ $scope.hoge()のみ発火します。

ng-clickの順番を逆にした場合
<button ng-click="piyo()" ng-click="hoge()">
→ $scope.piyo()のみ発火します。

ちなみに<button ng-click="hoge(), piyo()">みたいに書くと構文エラーで怒られます。

そういう時は

<button ng-click="wrapHogePiyo()">
$scope.wrapHogePiyo = function() {
  $scope.hoge();
  $scppe.piyo();
}
4
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?