angularjs-ng-click

AngularJS set ng-click function with scope variables within ng-repeat

让人想犯罪 __ 提交于 2019-12-08 02:41:19
问题 I would like to assign different functions to ng-click within ng-repeat: <button ng-repeat="button in notification.buttons" ng-click="button.fn"> {{button.label}} </button> Controllers: app.controller('MainCtrl', ['$scope', function($scope){ $scope.notification = { ctrl: 'logout', text: 'Logout?', buttons: [ {label:'Yes', fn: 'logout()'}, {label:'No', fn: 'cancel()'}, ], }; }]); app.controller('logout', ['$scope', function($scope){ $scope.logout = function(){ alert('logout'); }; $scope.cancel

How to invoke ng-click from a directive partial?

孤街醉人 提交于 2019-12-07 15:08:56
问题 I have a directive that has a local scope where a partial contains ng-click. The Fiddle is there: http://jsfiddle.net/stephanedeluca/QRZFs/13/ Unfortunatelly, since I moved my code to the directive, ng-click does not fire anymore. The controller and the directive is as follows: var app = angular.module('myApp', ['ngSanitize']); app.directive('plantStages', function ($compile) { return { restrict: 'E', transclude: true, template: '<figure class="cornStages">\ <p ng-transclude style="color:

how to use a model property as variable ng-click

纵然是瞬间 提交于 2019-12-07 05:47:44
问题 I'd like to have function calls for ng-click stored as strings in my model. I can't use ng-click="m.func", and if i'm using ng-click="{{m.func}}" ist also not working. http://jsfiddle.net/j8wW5/19/ It also looks like angular 1.2.0 throws an error in case of ng-click="{{m.func}}". How can I bring it to work? <div ng-app="myApp" ng-controller="myCtrl"> <div ng-repeat="m in model"><a href="#" ng-click="{{m.func}}">{{m.caption}}</a></div> </div> var app = angular.module('myApp', []); app

AngularJS set ng-click function with scope variables within ng-repeat

落花浮王杯 提交于 2019-12-06 10:32:55
I would like to assign different functions to ng-click within ng-repeat: <button ng-repeat="button in notification.buttons" ng-click="button.fn"> {{button.label}} </button> Controllers: app.controller('MainCtrl', ['$scope', function($scope){ $scope.notification = { ctrl: 'logout', text: 'Logout?', buttons: [ {label:'Yes', fn: 'logout()'}, {label:'No', fn: 'cancel()'}, ], }; }]); app.controller('logout', ['$scope', function($scope){ $scope.logout = function(){ alert('logout'); }; $scope.cancel = function(){ alert('cancel'); }; }]); If I put button.fn in double curlies ng-click="{{button.fn}}"

Angular: Add ngClick from js

做~自己de王妃 提交于 2019-12-06 03:24:41
I am developing small web page for mobile devices with Angular. I want to toggle click listener for whole page like $('.page').on('click',...); $('.page').off('click',...); but in Angular way. And I don't want to use ng-Click with some conditions because most of the time the click should not work, it is just for error handling. Is it possible or I need to user pure js/jQuery? Panel HTML: <div class="alert error" ng-show="errorMessage"> <div class="alert-text">{{ errorMessage }}</div> </div> I created a directive: It should be used in conjunction with ngIf . ngIf should refer to an assignable

How to add ng-click handler dynamically

一个人想着一个人 提交于 2019-12-06 02:33:16
问题 I tried to add ng-click on a button generated before (dynamic), but didn't work well. Also I tried already all solutions found on this forum and no one work well. My html code: <body class="max_height" ng-app="myApp"> <div class="container max_height" ng-controller="myCtrl"> <div id="play" tabindex="0" ng-init="init()" ng-keydown="keyDown($event)"> {{ content }} </div> </div> <script src="js/angular.min.js"></script> <script src="js/script.js"></script> </body> My AngularJS code: var app =

Angular scope and ng-click / ng-show to set multiple divs

痞子三分冷 提交于 2019-12-06 02:09:24
问题 I am looking for some help with my code I have so far. The main objective is to be able to click on any Plus icon and have it place a cover over all other div blocks. And when a plus icon is clicked it will also show a div block to the right. As you will see when block 2 is clicked it does all that is intended. I am looking for an efficient way to do this with Angular when any plus icon is clicked. This is just a small sample I show here, in reality there would be 10 to 20 blocks to cover. If

pass button id in ng-click angular.js

佐手、 提交于 2019-12-05 14:44:19
问题 I need to pass button id in Ionic Framework. Here is what I have tried. In js code: angular.module('todo', ['ionic']) .controller('TodoCtrl', function($scope) { { $scope.showAlert = function(btnId) { alert(btnId); }; } }); In html: <button id="a" class="button button-light" data="{{button.id}}" ng-click="showAlert(data.id)"> Click Me </button> O/P: undefined or <button id="a" class="button button-light" data="{{button.id}}" ng-click="showAlert(data)"> Click Me </button> O/P: undefined or

how to use a model property as variable ng-click

拟墨画扇 提交于 2019-12-05 11:39:58
I'd like to have function calls for ng-click stored as strings in my model. I can't use ng-click="m.func", and if i'm using ng-click="{{m.func}}" ist also not working. http://jsfiddle.net/j8wW5/19/ It also looks like angular 1.2.0 throws an error in case of ng-click="{{m.func}}". How can I bring it to work? <div ng-app="myApp" ng-controller="myCtrl"> <div ng-repeat="m in model"><a href="#" ng-click="{{m.func}}">{{m.caption}}</a></div> </div> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.model = [ { caption: 'callme a', func : 'callme_a()' }, {

Click event on glypicon

帅比萌擦擦* 提交于 2019-12-05 07:45:38
How do I add a ng-click event to a bootstrap glyphicon in a textbox? The event doesn't get fired... <body ng-app ng-init="mymodel='THIS IS MY MODEL'"> <h3>How to clear the model on remove icon click?</h3> <div class="container"> <div class="form-group has-feedback" > <input type="text" class="form-control" ng-model="mymodel"/> <i class="glyphicon glyphicon-remove form-control-feedback" ng-show="mymodel" ng-click="mymodel = null"></i> </div> <p>This is my model: {{mymodel}}</p> <strong ng-click="mymodel = null">This works tho...</strong> </div> </body> Plnkr link This is happening because