Compare MVVM WPF and MVC/MVVM AngularJS

MVVM Architure in WPF seems to be understandable.

  • The model in the MVVM pattern encapsulates business logic and data.( It is a specific class who in charge of the business login and data )
  • The view's responsibility is to define the structure and appearance of what the user sees on the screen. ( implements by having a XAML page )
  • The view model in the MVVM pattern encapsulates the presentation logic and data for the view.( It is a specific class who in charge of the presention login )
  • 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?

    下一篇: 比较MVVM WPF和MVC / MVVM AngularJS