angular为什么解决初始化数据为空显示
1个回答
展开全部
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<html>
<head>
<title>AngularJs Demo</title>
<script type='text/javascript' src="./angular.min.js"></script>
</head>
<body ng-app="myApp">
<h1>AngularJs Demo</h1>
<div ng-cloak ng-controller="DemoCtrl" ng-init="pageInit()">{{hello}}</div>
<script type='text/javascript'>
var app = angular.module('myApp', []);
app.controller('DemoCtrl', function($scope) {
$scope.pageInit = function() {
$scope.hello = 'Hello AngularJs';
}
});
</script>
</body>
</html>
保存为html, 当前目录需要angular.min.js文件.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<html>
<head>
<title>AngularJs Demo</title>
<script type='text/javascript' src="./angular.min.js"></script>
</head>
<body ng-app="myApp">
<h1>AngularJs Demo</h1>
<div ng-cloak ng-controller="DemoCtrl" ng-init="pageInit()">{{hello}}</div>
<script type='text/javascript'>
var app = angular.module('myApp', []);
app.controller('DemoCtrl', function($scope) {
$scope.pageInit = function() {
$scope.hello = 'Hello AngularJs';
}
});
</script>
</body>
</html>
保存为html, 当前目录需要angular.min.js文件.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询