Answer the question
In order to leave comments, you need to log in
How to set value on ng-click?
Hello, tell me please, there is a controller, in it $scope.template = '';
In the view I add to the element
<button ng-click="template = 2">Set template</button>
<button ng-click="setSelectedTemplate(2)">Set template</button>
Answer the question
In order to leave comments, you need to log in
Most likely your button is in ng-if
or in another directive that creates $scope
because of this the value is assigned somewhere there.
Alternatively, you can use it in the controller
$scope.customObj =
template: ''
ng-click = "customObj.template = 2"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question