这是我的角度代码,我需要通过var myval = "aaa,,,,bbb,,,,,,,ccc,,,,,,,,ddd,,,,,,,eee";
do {
myval = myval.replace(/,,/g, ',');
} while (myval.indexOf(",,") > 0);
console.log(myval);
函数接收对象,这个对象在ng-option中循环。但它不起作用;返回changeFilterOption(filter)
。
undefines
答案 0 :(得分:1)
在*.js
文件中,您可以watch
进行更改: -
$scope.$watch('your-model-name', function (newValue, oldValue){
//newVal is the changed value
});
答案 1 :(得分:1)
如果您需要将所选值传递给changeFilterOption
函数,那么这不是您需要遵循的方式,请尝试这样,
<select ng-change="changeFilterOption(attribute[' + countInc + '].name)" ng-model="attribute[' + countInc + '].name" ng-options="filter.name as filter.uiName for filter in filters">
这是demo
然后select
的值将传递给changeFilterOption(filter)
参数中的filter
。
如果您希望将filter
对象传递给changeFilterOption(filter)
,则需要修改select
,如下所示,
<select ng-change="changeFilterOption(attribute[' + countInc + '].name)" ng-model="attribute[' + countInc + '].name" ng-options="filter as filter.uiName for filter in filters">
这将选择filter
作为select
值,并将filter.uiName
显示为选项文字。
这是DEMO
答案 2 :(得分:0)
试试这个
<select ng-change="changeFilterOption(filter)" class="js-example-basic-single form-control" ng-model="attribute[' + countInc + '].name" ng-options="filter as filter.uiName for filter in filters"></select>
$scope.changeFilterOption=function(filter){
console.log(filter);//undefined
};