Reputation: 5
I have a $scope variable in controller and I want to access it in DOM in ng-init.
In controller -
$scope.value=true;
I want to check or unchecked checkbox based on $scope.value variable. For this I m doing this :
<input type="checkbox" ng-model="val" ng-init="val={{value}}">abc
but this isn't working...Any solution to this?
Upvotes: 0
Views: 3210
Reputation: 8365
You can just assign value in ng-init
<input type="checkbox" ng-model="val" ng-init="val=value">
For more information: angualr ngInit directive
Upvotes: 0
Reputation: 185
you can use
<input type="checkbox" ng-model="val" ng-init="val=value">abc
hope it helps
Upvotes: 0
Reputation: 724
First make sure that you are gave the root dom element in the view as ng-controller="controllerName" then try this
<input type="checkbox" ng-model="val" ng-init="val=value">abc
Try this
Upvotes: 1