简体   繁体   English

ng-init无法正常工作

[英]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. 我有一个要使用ng-init初始化的对象。 but when I see in the ng inspector, model value is always undefined. 但是当我在ng检查器中看到时,模型值始终是未定义的。 AID is dynamic value in the kendo grid. AID是剑道网格中的动态值。

   <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. 我希望模型ps ['test']为假。 But it is always undefined. 但是它始终是不确定的。 Please help 请帮忙

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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