我有一个指令,我试图将其设置ng-init
为一个变量集$scope
<select ng-init="safe.id=currentSafe" ng-options="safe as safe.name for safe in safes track by safe.id" ng-model="safe" ng-change="getSafeUrl(safe.id)"></select>
在link
指令的函数中,我有:
$scope.currentSafe = '72824ca7-99ab-4f16-a56c-3c98328c73fd';
这是行不通的。但是,如果我将模板更改为:
<select ng-init="safe.id='72824ca7-99ab-4f16-a56c-3c98328c73fd'" ng-options="safe as safe.name for safe in safes track by safe.id" ng-model="safe" ng-change="getSafeUrl(safe.id)"></select>
为什么我不能使用来自的字符串,$scope
但我可以直接使用它?