<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>value</title>
<script type="text/javascript" src="js/angular.js" ></script>
<script>
var app=angular.module("myApp",[]);
//只有$myConstant才能用,他可以在config进行操作,value不可以
// app.config(function($myConstant){
// num=$myConstant;
// });
app.controller("myCtrl",function($scope,$myValue){
$scope.num=$myValue;
});
//通过value创建值。
app.value("$myValue",1);
// app.controller("myCtrl",function($scope,$myConstant){
// $scope.num=$myConstant;
// });
//app.constant("$myConstant",2);
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<p>数字:{{num}}</p>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>value</title>
<script type="text/javascript" src="js/angular.js" ></script>
<script>
var app=angular.module("myApp",[]);
//只有$myConstant才能用,他可以在config进行操作,value不可以
// app.config(function($myConstant){
// num=$myConstant;
// });
app.controller("myCtrl",function($scope,$myValue){
$scope.num=$myValue;
});
//通过value创建值。
app.value("$myValue",1);
// app.controller("myCtrl",function($scope,$myConstant){
// $scope.num=$myConstant;
// });
//app.constant("$myConstant",2);
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<p>数字:{{num}}</p>
</body>
</html>