Compare MVVM WPF and MVC/MVVM AngularJS
MVVM Architure in WPF seems to be understandable.
Now lets compare it to Angularjs Design pattern MVC/MVVM.
The view is the DOM(html).
The ViewModel is:
the $scope object could be considered the ViewModel that is being decorated by a function that we call a Controller.
And Here Comes The Question
What is the Model in this AngularJS design pattern ?
I understood that maybe the Services should be the model ? can someone make it clear to me?
BTW i want to use ES6 Class to be the model as we talked about in the MVVM WPF Design pattern where the model is a Class .
模型可以来自服务或工厂,例如:
angular.module("myModule")
.factory("urlFactory", function() {
return {
myModelSource: 'http://localhost:38324/api/myModel'
}
})
.service("dataSource", ["$http", "urlFactory", function($http, urlFactory) {
return {
getMyModel: function() {
return $http.get(urlFactory.myModelSource);
}
}
}])
.controller("myController", ["$scope", "dataSource", function($scope, dataSource) {
dataSource.getMyModel().then(function(myModel) {
$scope.viewModel = myModel;
});
}]);
链接地址: http://www.djcxy.com/p/63370.html
上一篇: MVC,MVA,MVP,MVVM?