, , :
( ) , viewmodel , :
$scope.errors = myModel.update($scope.formFields);
, :
$scope.$watch('formFields', function (values) {
$scope.errors = myModel.validate(values);
});
$scope.submit = function () {
$scope.errors = myModel.update($scope.formFields);
if ($scope.errors.length < 0) {
$scope.formFields = {};
$scope.showForm = false;
}
};
, .
:
var items = {};
return {
'getItems': function () {
return items;
}
};
:
$scope.myList = myListModelService;
:
<li ng-repeat="item in myList.getItems()">
, / ($scope.myList.getItems().push(newItem);). , : " , - API- " () , : " - ". , , , , - , :).
, getter Angular $watch, .