Search Posts

Category: angularjs-ng-click

Angular 1.4 – How to move logic for ng-click item from template to controller?

I am looking to modify some code to add more functionality to an ng-click event that is within an ng-repeat. The current code updates the selected property for the item in the list: <li ng-repeat=”value in facet.values ng-click=”value.selected = (value.selected == 0) ? 1 : 0; accountSearch()”> … </li> I’d like to update the selected property but also fire an event to our analytics provider: <li ng-repeat=”value in facet.values ng-click=”itemClicked(value)”> … </li> Then in my […]

One way data binding inside ng-click

I have two $scope array inside my controller. $scope.arrayA= [false, false, false, false, false, false]; $scope.arrayB= [false, false, false, false, false, false]; arrayA will change depends on checkbox click. I have done this part. arrayB will change values to be equal to arrayA only when a button is clicked. <button type=”button” ng-click=”arrayB = arrayA” class=”btn btn-search”>Get Data</button> The problem is once the button is clicked, two way data binding is implemented. arrayB will change everytime […]

AngularJS issue with ng-click and 2 expressions inside, only one fires

I have an issue, in a ng-click I have 2 expressions, and only one fires. If I use only one expression at a time, they both work, but together they dont. One is a function, and one is a simple: button = !button ; which I use to trigger the button state. All of this is inside a ng-repeat, so I’ll get multiple buttons, and each has to have its own state. What I saw […]

How to invoke a function as dynamically string in AngularJS?

How to use a function assigned variable in ng-click?? I have tried three ways below, but that’s also not working. Could you please let me know is it possible or not??? if yes, then how? var app = angular.module(“app”, []); app.controller(“name”, function($scope) { $scope.showname = function() { alert(“Ramesh”); } $scope.variable1 = $scope.showname; $scope.variable2 = “showname()”; }); <script src=””></script> <div ng-app=”app” ng-controller=”name”> <button type=”button” ng-click=”variable1″ tabindex=”10003″ >Not working 1 </button> <button type=”button” ng-click=”$scope[variable2]()” tabindex=”10003″ >Not working […]

send value to controller in angularjs and return array

I want send cod to controller and return array When pressing a li you have to send a code to the controller, in this case I am setting the example 7. Once the code has arrived at the controller I will have a list that I have to show in a ng-repeat table SCRIPT <script type=”text/javascript”> var app = angular.module(‘myApp’, []) app.value(‘studentInfo’, [ { id: 1, name: ‘Mahedee Hasan’, credit: 20, semester: ‘8th’ }, { […]

AngularJS ng-click only working on second click

Attempting to collapse a dropdown menu (language selection), within a mobile bootstrap navbar. On first click, the dropdown menu with the languages opens fine, after changing languages the dropdown language menu closes, but when I attempt to change the language again, I have to double click the dropdown for it to open. Can anyone help me with this? <li class=”dropdown” dropdown style=”margin-top: 25%; left: 7.5%;”> <a href=”#” class=”dropdown-toggle” dropdown-toggle role=”button” ng-click=”visible = true”> {{}} <span […]

Click Button to show another button and opposite

I am wanting to have the Resolve Ticket Button showing when the open item is an Incident. When I click Resolve Ticket, I want Cancel and Confirm buttons to show. However, when you click Cancel I need Resolve Ticket to show again. I can get Cancel/Confirm to show, but clicking Cancel does nothing. The HTML is below. <div class=”panel b” ng-if=” == true”> <div class=”panel-heading bg-primary”> <div class=”panel-title”>Is this no longer an issue?</div> </div> <div […]

How do I append "ng-click()" to <img> tags on an array of dynamically added html?

how to How do I append "ng-click()" to <img> tags on an array of dynamically added html? I’m very new to AngularJS and I’m figuring out how to add an ng-click on all img tag so I can get a display what I click them. The logic I’m thinking is using angular.foreach to track all the contents of the array with regex and append their src’s along with an ng-click. Here’s code for scouring the […]

Button working only on second click (any 2 clicks each)

I have a simple, but annoying problem: In my fragment, I have a button which should call function. but I have to click the button twice (any 2 clicks it works, but when i debug it any time I click the button the function is running , but only the second time I can see my output on the screen). HTML: <div class=”container”> <button ng-click=”$ctrl.getObject()” > GET MOVIES </button> </div> component: ‘use strict’; const appModule […]

Next Page »