I am trying to show different graphs for different schools, and the button does not fire when clicked.
I have this in my html file:
<button ng-repeat="datarow in testData | unique:'school_name'" ng-click="showlinegraph(testData)">
{{datarow.school_name}}</button>
And my controller:
$scope.showlinegraph = function(data) {
$scope.showgraph = ! $scope.showgraph;
console.log(data);
}
I've been stuck on this for a while, and the issue i think has to do with the ng-repeat because a button without it, successfully calls the controller method.
<button ng-click="showlinegraph(testData)">
Toggle Graph
</button>
The button with ng-repeat doesn't even depress when clicked on.
Try in the controller to find the school_name
and just print it in the button label. perhaps the ng-click
event couldn't fire because you're using ng-for
too...
I mean, in you controller file do a foreach
and find the school_name
in the object then store the school_name
into a variable and print that variable in the button. And must work properly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.