有两个不同的控制器,一个用于语言,langCntl一个用于单词,一个wordCntl。
在wordCntl记录中有一个属性叫做ln. 根据控制器中的记录,ln使用ng-select, 以表格形式显示。ngOptionslangCntl
记录更改时如何select进行ln刷新?wordCntllangCntl
langMod.js
var langMod = angular.module('langMod', ['ngResource']);
langMod.controller('langCntl',function($scope,$http) {
$scope.langs = [];
$scope.reset = 函数() {
$http.get('/lang.jsn').success(函数(数据){
console.log('http.success: data='+data);
$scope.langs = angular.copy($scope.origs);
});
};
$scope.reset();
});
langMod.controller('wordCntl',function($scope) {
var langElem = document.querySelector("[ng-controller='langCntl']");
$scope.langs = angular.element(langElem)).scope().langs;
$scope.rcd = { ln: 'en', word: '?' };
});
索引.html
<html lang='en' ng-app='langMod' >
<正文>
<ng-form ngForm='abc' ng-controller='wordCntl' >
<select ng-model="rcd.ln" ng-options="c.lang as c.name for c in langs">
</ng-form>
</正文>
</html>
有什么有趣的(对我来说):
langCntl.langs更改后,wordCntl.langs仍然是一个空数组。- 在中
ngoptions,有没有办法直接使用中的记录langCntl?