Having multiple values to send, such as those needed for customer user creation.
Here is where I found a solution: (Using an object array as input data)
I adapted the code to extract only the true knowledge values.
Upon inspecting my button, an error occurred:
Array[0]
TypeError: Cannot read property 'map' of undefined
HTML view:
<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);
}
EDIT (Update)
After examining this image, it seems that the values are not being retrieved.
In my code, I have utilized the following method:
$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");
}