<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<meta http-equiv= "x-ua-compatible" content= "Ie=edge"/>
<meta name= "viewport" content= "width=device-width,initial-scale=1"/>
<title></title>
<meta charset= "Utf-8"/>
<link rel= "stylesheet" href= "Bootstrap-3.3.5/dist/css/bootstrap.min.css"/>
<body data-ng-app= "myApp" data-ng-controller= "Myctrl" >
<div class= "Container" style= "padding:50px" >
<div data-ng-model= "MESG" >
<p>{{realName}}</p>
<p>{{Http}}</p>
<p>{{data.msg}}</p>
<p>{{name}}</p>
</div>
</div>
<script src= "Jquery/jquery-2.1.4.js" ></script>
<script src= "Bootstrap-3.3.5/dist/js/bootstrap.min.js" ></script>
<script src= "Http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js" ></script>
<script src= "Js/app.js" ></script>
</body>
App.js
Angular.module ("myApp", [])
. Value ("Realname", "Zhaoliu")
. Constant ("http", "www.runoob.com")
. Factory ("Data", function () {
return {
msg: "Hello!" ",
Setmsg:function () {
this.msg= "2016 Financial color and collection"
}
}
})
. Service ("User", function () {
This.fname = "Melao";
This.lname = "2006";
This.getname = function () {
Return This.fname+this.lname
}
})
. Controller ("Myctrl", Function ($scope, realname,http,data,user) {
$scope. MESG = "Hello AngularJS";
$scope. realname = Realname;
$scope. HTTP = http;
$scope. data = data;
Data.setmsg ();
$scope. Name = User.getname ();
})
Customizing services Services in Angularjs