Angular - click doesn't work


Highest

I think I have:

<button ng-click="getPerson()">test</button>
<ul>
    <li ng-repeat="person in persons">{{ person.name + ' - ' + person.username }}</li>
</ul>

The ul part is working fine, but when I click the button getPerson() is not called? The alert is not displayed.

my controller:

app.controller('personsController', function ($scope, personsService) {
getPersons();
function getPersons() {
    personsService.getPersons()
        .success(function (persons) {
            $scope.persons = persons;
        })
        .error(function (error) {
            $scope.status = 'Error: ' + error.message;
        });
}

function getPerson() {
    alert('tst');
}
}); 

Am I doing something wrong?

tyme joint venture

The function must be in $scope: Change:

function getPerson() {

to:

$scope.getPerson = function() {

Related


Angular - click doesn't work

Highest I think I have: <button ng-click="getPerson()">test</button> <ul> <li ng-repeat="person in persons">{{ person.name + ' - ' + person.username }}</li> </ul> The ul part is working fine, but when I click the button getPerson() is not called? The aler

Click doesn't work in angular

Lucas Castro Below is the code. Click event doesn't work for navigating hamburger and hiding menu. Menu components: section class="hero outer is-primary is-fullheight animated slideInLeft" [ngClass]="{'is-hidden' : !menu.opened}"> menu.service.ts: @Injectable

Angular - click doesn't work

Highest I think I have: <button ng-click="getPerson()">test</button> <ul> <li ng-repeat="person in persons">{{ person.name + ' - ' + person.username }}</li> </ul> The ul part is working fine, but when I click the button getPerson() is not called? The aler

Angular click doesn't work in div

Carlos Rodriguez Well I've been here for a while and I'm sure this is relatively stupid http://plnkr.co/edit/YcBnbE5VCU5rizkDWreS?p=preview <head> <link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />

Angular HTTP doesn't work on first click

Nafis Mustak When the button is clicked, I am calling a method Getdata(); but the problem is when the page loads for the first time, if I click the button, I get a "HTTP Error" response. But if I click the button again, it shows a success response. HTML <butto

Angular click doesn't work in div

Carlos Rodriguez Well I've been here for a while and I'm sure this is relatively stupid http://plnkr.co/edit/YcBnbE5VCU5rizkDWreS?p=preview <head> <link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />

Angular click doesn't work in div

Carlos Rodriguez Well I've been here for a while and I'm sure this is relatively stupid http://plnkr.co/edit/YcBnbE5VCU5rizkDWreS?p=preview <head> <link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />

Angular click doesn't work in div

Carlos Rodriguez Well I've been here for a while and I'm sure this is relatively stupid http://plnkr.co/edit/YcBnbE5VCU5rizkDWreS?p=preview <head> <link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />

doesn't work on click

Rahul Sharma Hi guys, I'm designing a "Help" button on the main menu on an app. I copied the custom help image file into the drawable folder and created a Help.xml file to embed it in the layout. My function requires that just clicking this help button on the

doesn't work on click

Rahul Sharma Hi guys, I'm designing a "Help" button on the main menu on an app. I copied the custom help image file into the drawable folder and created a Help.xml file to embed it in the layout. My function requires that just clicking this help button on the

Click doesn't work?

MRC On each page of the website, each page of the menu has a different class that moves the menu image up and down to display the image of choice. Just to give the impression of fast loading for the page switching effect, I need to use JS to position the backg

doesn't work on click

Rahul Sharma Hi guys, I'm designing a "Help" button on the main menu on an app. I copied the custom help image file into the drawable folder and created a Help.xml file to embed it in the layout. My function requires that just clicking this help button on the

click and show doesn't work with dynamic content (angular)

value_ Why does Ng-click and ng-show not work on dynamic content, while if I try to toggle static labels everything works fine? What do I need to do so I can click the sink profile tab? How can I achieve the desired effect with the smallest code footprint? I h

Angular ng-click doesn't work with $compile

freddy83 I have code similar to the following code to trigger events in an clickAngular app . Why doesn't the event fire? var app = angular.module("myApp", []) app.directive('myTop',function($compile) { return { restrict: 'E', template: '<div></div>',

Angular toggle variable in ng-click doesn't work

amnesia I have a table that lists customers, and for customers that also have a list of customers, the user can click on the table row to display that list. HTML looks like this: <tbody ng-repeat ="item in customers | clientSettingsFilter:customerId">

ng-click doesn't work in angular-ui-grid

username I'm trying to fire a click event when a cell in ui-grid is clicked but ng-click is not working. Also ng-class doesn't work, I can't get width: "*" works fine. Does anyone know any accurate documentation for angular-ui-grid ? I am using angular v 1.5.1

Angular-js: ng-click doesn't work

Shiva Since I'm very new to angular js, I'm trying to develop small applications, but I'm stuck because ng-click is not working. please help. Thanks in advance. Here is my code: HTML file: <html ng-app="MyApp"> <head> <title>Angular Demo App</title>

click and show doesn't work with dynamic content (angular)

value_ Why does Ng-click and ng-show not work on dynamic content, while if I try to toggle static labels everything works fine? What do I need to do so I can click the sink profile tab? How can I achieve the desired effect with the smallest code footprint? I h

Changing color of class on click doesn't work Angular 2

Kappa I'm making an app in Angular 2 that functions like stackoverflow up and down votes , the app works fine in my Visual Studio Code. question: (1) Why are up and down arrows not showing up in Stackblitz my app StackBlitz (2) I want to change the color of th

ng-click doesn't work in angular js

Himanshu N Tatariya I am using Angular js from one of my projects and calling the "ng-click" function as follows <a ng-click="logout'{{x.ParentEntityId['#text']}}')" target="_blank">{{x.Title["#text"]}}</a> In "x.ParentEntityId['#text']" the value is "7560183

angular.element triggering click event doesn't work

cyst I've been trying to trigger a click event in an input element using angular ng-click on other elements like this: html <div class="myClass" ng-click="vm.selectImage()" nv-file-drop uploader="vm.uploadImage"> Drop your image here </div> <div ng-hide="!

Angular ng-click doesn't work with $compile

freddy83 I have code similar to the following code to trigger events in an clickAngular app . Why doesn't the event fire? var app = angular.module("myApp", []) app.directive('myTop',function($compile) { return { restrict: 'E', template: '<div></div>',

click and show doesn't work with dynamic content (angular)

value_ Why does Ng-click and ng-show not work on dynamic content, while if I try to toggle static labels everything works fine? What do I need to do so I can click the sink profile tab? How can I achieve the desired effect with the smallest code footprint? I h

Angular: Update model doesn't work with continuous click events

under_score So I have a div that uses the *ngFor property to iterate and populate the table. On the loop, I use it's data value to assign the div's background color. As follows: <div class="col-xs-1-10" *ngFor="let item of combinations"> <div [style.background

Angular ng-click doesn't work with $compile

freddy83 I have code similar to the following code to trigger events in an clickAngular app . Why doesn't the event fire? var app = angular.module("myApp", []) app.directive('myTop',function($compile) { return { restrict: 'E', template: '<div></div>',