<! DOCTYPEHTML> <HTMLng-app="MYAPP"> <Head> <Metacharset="UTF-8"> <title>title</title> <Scriptsrc="Js/angular.min.js"></Script> </Head> <Bodyng-controller="My"> <spanng-bind="name1"></span> <spanng-bind="name2"></span> <spanng-bind="Name3"></span> </Body> <Script>varapp=angular.module ("MYAPP",[]);app. Controller ("My",["$scope","Serv","Serv2","Serv3",function($scope, S1,S2,S3) {$scope.name1=S1; $scope.name2=S2; $scope.Name3=S3; }])///factory method to implement custom services in the project is more frequent,//in its simple syntax and use of popularapp. Factory ("Serv",function() {var_v="The first kind of factory";return_v;
})//service mode implementation of custom services, the returned data must be a JSON object,//In some projects in order to standardize the return value of the data, the Convention uniformly use the object for processing. Service is more consistent with this specification, so use more frequentlyapp. Service ("Serv2",function() {return{_V2:"Second Service"}; })//provider custom service, used more inside the angular framework,//Because the code operation more tends to lower the level of code readability,//For the General project development has some difficulty, so project development uses lessapp. Provider ("Serv3",function() { This. $get =function() {return{_v3:"The Third Kind of provider"}; }}) </Script> </HTML>