用户首先在界面中进行人机交互,而后请求发送到控制器,控制器根据请求类型和请求的指令发送到相应的模型,模型能够与数据库进行交互,进行增删改查操做,完成以后,根据业务的逻辑选择相应的视图进行显示,此时用户得到这次交互的反馈信息,用户能够进行下一步交互,如此循环。 html
模型Model:存储数据的实体模型,操做数据的业务模型前端
视图View:显示数据,响应用户操做, 与用户进行交互数据库
控制器Controller:操做模型数据, 更新视图,是View与Model之间的桥梁express
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <meta http-equiv="X-UA-Compatible" content="ie=edge"> 7 <title>Document</title> 8 </head> 9 <body ng-app="myApp"> 10 <!-- ng-app 的值指向对应的模块对象的名字 --> 11 <div ng-controller="myController"> 12 <input type="text" ng-model="firstName"> 13 <p>员工1:{{firstName}}</p> 14 15 </div> 16 <div ng-controller="myController2"> 17 <input type="text" ng-model="firstName"> 18 <p>员工2:{{firstName}}</p> 19 </div> 20 21 <script src="../js/angular-1.5.5/angular.js"></script> 22 <script> 23 // 控制器的使用 angular 能够链式调用 24 angular.module('myApp',[]) 25 .controller('myController',['$scope', function ($scope) { // 显示声明依赖注入 26 $scope.firstName = 111; 27 }]) 28 .controller('myController2',['$scope', function ($scope) { 29 $scope.firstName = 222; 30 }]) 31 32 </script> 33 </body> 34 </html>
<body ng-app="myApp"></body>
<input type="text" ng-model="username"> <p>您输入的内容是:<span>{{username}}</span></p>
<div ng-app ng-init="username='Tom'"> <input type="text" ng-model="username"> <p>姓名1:{{username}}</p> <input type="text" ng-model="username"> <p>姓名2:{{username}}</p> </div>
<div style="width: 200px;height: 200px;" ng-style="myStyle" ng-mouseenter="enter()" ng-mouseleave="outer()"></div>