简体   繁体   中英

ng-init is not working as expected

I am trying to initialize model value as per the column value of the grid. I have this object which I want initialize using ng-init. but when I see in the ng inspector, model value is always undefined. AID is dynamic value in the kendo grid.

   <input type="checkbox" ng-init=""obj['#: AID#']='Y'"" ng-model=""obj['#: AID#']"">

controller:

 var testController = function($scope){
        $scope.obj= {};
 }

this is how final markup looks like

<input type="checkbox" ng-init="ps['test']=('Y' == 'N')" ng-model="ps['test']" class="ng-pristine ng-valid ng-touched">

I expect the model ps['test'] to be false. But it is always undefined. Please help

尝试将值设置为true或false,而不是Y或N。如下所示

<input type="checkbox" ng-init="obj['m']=true" ng-model="obj['m']">

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM