i need to set the model for a textfield to one of a number of items
but can't seem to figure out how to do it in 10.6
in 10.5 i could do something like:
ng:model="getMyModel('filterString')"
and in the controller do:
getMyValues = function(filterString) {
for (var a in self.list) {
if (self.list[a].name === filterString)
return self.list[a].values;
}
};
since jsfiddle is down i must post the code here but here is an
example:
<div ng:app="MyApp">
<div ng:controller="CtrlA">
<select ng:options="
l.name for l in list"
ng:model="selection">
</select>
<textarea type="myWidget"
ng:model="getMyValues()"></textarea>
Selection: {{
selection.name}}
</div>
</div>
var appModule = angular.module('MyApp', []);
appModule.value('MySelection',{name:''});
appModule.value('MyList',[{name:'test1'},{name:'test2'}]);
appModule.value('MyOtherList',[
{name:'test1', values:['a','b']},
{name:'test2', values:['c','d']}
]);
function CtrlA(MySelection, MyList) {
var self = this;
self.list = MyList;
self.selection = MySelection;
self.getMyValues = function() {
for (var a in self.list) {
if (self.list[a].name ===
selection.name)
return self.list[a].values;
}
};
}
CtrlA.$inject = ['MySelection','MyList'];
angular.inputType('myWidget', function() {
this.$parseModel = function() {
if (this.$modelValue) {
var x = "";
for (var a in this.$modelValue)
x += this.$modelValue[a].optionValue+' and ';
this.$viewValue = x;
}
};
this.$parseView = function() {
var vals = this.$viewValue.split(' and ');
for (var a in vals)
this.$modelValue[a].optionValue = vals[a];
};
});
angular is awesome it's just taking some work to get my hear around
it.
thanks very much!
007