帽子是我如何擁有多個值,我將發送它以繼續喜歡客戶可以創建的用戶。發送數組 - 無法讀取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 –