<!DOCTYPE html>
<html ng-app="moduleName">
<head>
<meta charset="UTF-8">
<title>Angular四大核心特性</title>
</head>
<body>
<!--
1. MVC
model:数据模型层 eg:{{hello}}
view:视图层,负责展示 eg: p标签
controller:业务逻辑和控制逻辑 eg:ng-controller="controllerName"
2. 模块化(module)
$scope': 依赖注入
ng-app="moduleName"
3. 指令系统 eg:自定义标签
4. 双向数据绑定
-->
<div ng-controller="controllerName">
<p>{{text}},Angular</p>
<hr>
<hello></hello>
<hr>
<input type="text" ng-model="name">
<br><p>{{name}},你好</p>
</div>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script>
var MyModule = angular.module("moduleName" , []);
MyModule.controller("controllerName" , ['$scope',
function f1($scope){
$scope.text = "hello";
}
]);
MyModule.directive("hello", function(){
return {
restrice:'E',
template:'<div>hello everyone</div>',
replace: true
}
});
</script>
</body>
</html>
Angular 四大核心特性
最新推荐文章于 2018-11-19 18:35:14 发布