angular- bind form submit with multiple buttons

Issue I have a form with multiple submit buttons: <form name=”myForm” customSubmit> <input type=”text” ng-minlength=”2″> <button type=”submit” ng-click=”foo1()”></button> <button type=”submit” ng-click=”foo2()”></button> </form> and a directive: angular.module(‘customSubmit’, []) .directive(‘customSubmit’, function() { return { require: ‘^form’, scope: { submit: ‘&’ }, link:

Continue reading

AngularJS 1st ng-class works 2nd doesn't

Issue I have the following: <div data-ng-controller=”resultsController”> <div id=”DIV1″ ng-include src=”‘views/sidebar.html'” ng-class=”showSidebar ? ‘open’ : ‘closed’ “></div> <div id=”DIV2” ng-class=”showSidebar ? ‘open’ : ‘closed’ “></div> And within ( ng-include src=”‘views/sidebar.html’” )^ i have the following div with ng-click which triggers

Continue reading

ng-click change class to selected button

Issue i want to change class btn-white to btn-primary for the selected Button $scope.SelectedCombination = function (combinationId) { $scope.selectedCombination =combinationId; }; html <button ng-repeat=”combination in combinations” class=”btn btn-white” ng-model=”” value=”{{combination.combinationId}}” ng-click=”SelectedCombination(combination.combinationId)” type=”button”>{{combination.name}}</button> Solution use ng-class.don’t use any javascript function to

Continue reading

How can I apply ng-style dynamically if ng-class is true?

Issue .test{color:red;background:blue;} .test.selected { position:relative; left: 100px; padding:10px; background:green; } <div ng-style=”myStyle” ng-class=”{select: x.selected}” ng-click=”select(x)” ng-repeat=”x in myData” class=”test”></div> $scope.select = function (text) { text.selected = true; }; $scope.myStyle = { ‘color’:’white’, ‘font-weight’:’bold’ } When the div element has className

Continue reading

ng-click not working in ng-repeat

Issue NG-click not firing in ng -repeat. I want to use ngclick to display only the specific element details. <body ng-app=”mainApp” > <div ng-app = “mainApp” class=”container” ng-controller=”TableFilterController”> <table ng-app = “mainApp” class =”table table-hover”> <tr><th>Id</th><th>Name</th><th>Age</th><th>Role</th></tr> <tr ng-repeat=”p in details

Continue reading

How/when to use ng-click to call a route?

Issue Suppose you are using routes: // bootstrap myApp.config([‘$routeProvider’, ‘$locationProvider’, function ($routeProvider, $locationProvider) { $routeProvider.when(‘/home’, { templateUrl: ‘partials/home.html’, controller: ‘HomeCtrl’ }); $routeProvider.when(‘/about’, { templateUrl: ‘partials/about.html’, controller: ‘AboutCtrl’ }); … And in your html, you want to navigate to the about

Continue reading

AngularJS Disable ngClick

Issue In AngularJS, is there any way to make an ng-click dependent upon a boolean? For example, I’d like the following text (“Click”) to be clickable, but only when some scope property (e.g., $rootScope.enableClick) is true. <div ng-click=”count = count

Continue reading

how to call a function from template literal on ng-click

Issue I am calling a function close_popup from template literal. I want to pass a variable id. Below is the code function register_popup(id, name) { var htmlelement = `<div class=”popup-box chat-popup” id=”${id}”> <div class=”popup-head background-purple-gradient”> <div class=”popup-head-left”>${name}-${id}</div> <div class=”popup-head-right”> <span

Continue reading

ng-click on firing on mobile or tablet devices

Issue On page load i have a controller that calls a service and then binds the returned data to some $scope.objects: app.controller(“MainController”, function($scope, $http, serviceGetData) { serviceGetData.getData(function(data) { $scope.LoginCount = data.LoginCount; $scope.ProductInfo = data.ProductInfo; $scope.ProfileInfo = data.ProfileInfo; // Delayed binding

Continue reading

{{}} in ng-click & ng-repeat

Issue This is the code of my HTML <div id=”container” ng-app=”containArea” ng-controller=”myCtrl”> <div id=”sidebody” class=”block”> <button ng-repeat=”shopli in shopName” ng-click=”openurl({{‘\”+shopli.url+’\”}})” class=”btn_shopList”> {{shopli.name}} </button> </div> …….. </div> And the JS here var app = angular.module(‘containArea’, []); app.controller(‘myCtrl’, function($scope) { $scope.shopName=[ {

Continue reading

Pass callback function to directive

Issue I’m trying to pass a callback function from a controller to a directive. Here’s the callback function code: $scope.onImageSelect = function(image) { alert(‘SET’); $scope.card.image = image; }; Directive usage: <google-image-search callback=”onImageSelect” /> Directive code: ngmod.directive(‘directive’, function() { return {

Continue reading

Angularjs ng-click doesn't update view

Issue myApp.controller( ‘ModalNewInstanceCtrl’, [ ‘$scope’, ‘$modalInstance’, function( $scope, $modalInstance ) { $scope.tabSelected = 0; $scope.saveFactor = function () { console.log(‘here’); $scope.tabSelected = 0; console.log($scope.tabSelected); }; That’s my controller. <div class=”modal-header”> <div ng-click=”tabSelected = 0″>Tab 1</div> <div ng-click=”tabSelected = 1″>Tab 2</div>

Continue reading

$compile not triggering ng-click in angularjs

Issue I am generating dynamic html element from angularjs controller.I have used $compile to make ng-click work inside html element.But still it is not calling the function. Here is my js var accountApp = angular.module(‘accountApp’, [‘ngRoute’]); accountApp.config([‘$compileProvider’,function($compileProvider ) .controller(‘myController’,function($scope,$compile) {

Continue reading

Why does ng-click not fire functions when inside ng-repeat, in AngularJS?

Issue I am working on a small AngularJS application. In one of the views, I have replaced some hard-coded html with data coming from a JSON file that I iterate through: <class=”actions-list”> <div ng-repeat=”item in $ctrl.myCustomService.config.items” ng-class=”{‘disabled’: !item.isEanabled}” class=”actions-item” ng-click=”$ctrl.selectAction(‘{{item.action}}’)”>

Continue reading

Get all data from form by ng-click AngularJs

Issue <script src=”//ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.min.js”></script> <div ng-app=”myApp”> <div class=”container” ng-controller=”CtrlList”> <div class=”row”> <div ng-repeat=”x in users track by $index”> <div><input type=text ng-model=”x.id”></div> <div><input type=text ng-model=”x.title”></div> <div><input type=text ng-model=”x.completed”></div> </div> <button ng-click=”submit(x)”>save </button> </div> In Controller $scope.submit = function(data){ console.log(data) // undefined }

Continue reading

How to trigger ngClick programmatically

Issue I want to trigger ng-click of an element at runtime like: _ele.click(); OR _ele.trigger(‘click’, function()); How can this be done? Solution The syntax is the following: function clickOnUpload() { $timeout(function() { angular.element(‘#myselector’).triggerHandler(‘click’); }); }; // Using Angular Extend angular.extend($scope,

Continue reading