Cannot get ng-click to work for div or span

I am trying to use ng-click for both div and span and cannot make it work.

 <body ng-controller="MainCtrl"> <div ng-click="infoClicked('work_please')"> tony magoo </div> <div> For general inquiries, please see our <span class = "highlight" ng-click = "infoClicked('work_span_please')">Frequently Asked Questions</span> </div> </body> 

and...

 var app = angular.module( 'plunker', [] ); app.controller('MainCtrl', function( $scope ) { $scope.name = 'World'; $scope.infoClicked = function( message ) { alert( message ); } }); 

Here is plunk

+4
source share
1 answer

You are missing the ng-app tag.

 <body ng-app="plunker" ng-controller="MainCtrl"> 
+5
source

Source: https://habr.com/ru/post/1496100/


All Articles