帽子是我如何拥有多个值,我将发送它以继续喜欢客户可以创建的用户。发送数组 - 无法读取undefined的属性'map'
我在这里找到:https://stackoverflow.com/a/14520103/7180653(与对象数组作为输入数据)
我根据他的代码需要,这是我应该怎么只有这是真正的知识的价值。
当我看着我的按钮。所以我得到这个错误:
Array[0]
TypeError: Cannot read property 'map' of undefined
HTML - 视图:
<ul style="list-style-type:none;">
<li class="col-md-4" ng-repeat="Value in ColorAddUppers">
<img ng-src="{{Value.Image}}" class="img-responsive img-rounded mb-lg" />
<p class="label label-lg label-primary full-width">
<input type="checkbox"
ng-model="Value.selected"
name="selectedColorUppers[]"
value="{{Value.IDColor}}" />
{{Value.Text}}
</p>
</li>
</ul>
CreateUser.js
var url = "/JsonClass/ColorAddToUppers";
$http.get(url).success(function (response) {
$scope.ColorAddUppers = response;
});
//Overdel
$scope.NextLvlThree = function() {
//Check Color Values
$scope.selectionColorUppersView = [];
$scope.selectedColorUppers = function selectedColorUppers() {
return filterFilter($scope.ColorAddUppers, { selected: true });
};
$scope.$watch('fruits|filter:{selected:true}', function (nv) {
$scope.selectionColorUppersView = nv.map(function (ColorNameUppersText) {
return ColorNameUppersText.Text;
});
}, true);
console.log($scope.selectionColorUppersView);
}
EIDT(更新)
当我看着这张照片时,就像它没有得到我的价值。
我已经在代码中使用这样的:
$scope.selectedTextValuesByWatch = [];
$scope.$watchCollection('ColorAddUppers|filter:{selected:true}', function (nv, ov) {
$scope.selectedTextValuesByWatch = nv.filter(function (value) {
return value.selected;
}).map(function (value) {
return value.Text;
});
}, true);
$scope.getSelectedTextValues = function() {
return $scope.ColorAddUppers.filter(function (value) {
return value.selected;
}).map(function (value) {
return value.Text;
});
}
console.log($scope.selectedTextValuesByWatch);
if($scope.selectedTextValuesByWatch.length >= 1)
{
console.log("check");
}
else
{
console.log("error");
}
哦,男人,这是英语吗?你确定'fruits'是在应用程序的某个地方定义的吗? –
@AbbéRésinaohh我需要删除'fruits'我试图说:'$ scope。$ watch('Value | filter:{selected:true}',' –
$ scope。$ watch只返回对象,尝试使用$范围。$ watchCollection –