ng init未按预期工作

ng-init is not working as expected

本文关键字:工作 init ng      更新时间:2023-09-26

我正在尝试根据网格的列值初始化模型值。我有这个对象,我想用ng init初始化它。但是当我看到ng检查器,模型值总是未定义的。AID是剑道网格中的动态值。

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

控制器:

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

这就是最终标记看起来像的样子

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

我预计模型ps("测试")是假的。但它总是不明确的。请帮助

尝试将值设置为true或false,而不是Y或N

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