Before posting a blog post, from the mobile angular UI of the demo and its official website to understand the general use of the whole angularjs, but not very good study, just through some technical blog preliminary understanding, into a lot of pits. So now in the Civil Service network formally organized under the Knowledge point consolidation
- Template built-in directives
Boot program Ng-app
Set Variable Ng-model
Get variable {{}}
Traverse ng-repeat= "row in rows"
Search function ng-repeat= "row in rows | Filter: Query variable name "
Sort function ng-repeat= "row in rows | ORDER BY: Sort variable name "
Picture ng-src= "{{}}"
- Angularjs built-in methods
- Defined items: Jsgen = Angular.module ("Jsgen", ["Nglocale", "Ngroute", "Nganimate", "Ngresource", "Ngcookies", "Ui.validate", " Gentemplates "," angularfileupload "]);
- Initialized: Jsgen.run (["App", "$q", "$rootScope", "$location", "$timeout", "$filter", "GetFile", "Jsonkit", "toast", "timing", " Cache "," Restapi "," sanitize "," Mdparse "," Mdeditor "," Cryptojs "," Promiseget "," myconf "," Anchorscroll "," isVisible "," Applyfn "," Param "," store "," I18n-zh ",
- Define constants: Jsgen.constant ("App", {url: ', Version:Date.now ()}
- Configure the route: Jsgen.config (["$routeProvider", "$locationProvider",]), configure HttpProvider:jsGen.config (["$httpProvider", " App "]);
- Interface services: Jsgen.factory ("Restapi", ["$resource",]), Factory mode: Jsgen.factory ("I18n-zh", ["$locale"]); Cache: Jsgen.factory ("Cache", ["$cacheFactory"]);
- Filter: Jsgen.filter ("placeholder", ["Jsonkit"])
- define Directive (binding event): Jsgen.directive ("Gentabclick", function () {});
- Define controller: Jsgen.controller ("Indexctrl", ["app", "$scope", "$routeParams", "getList"])
Controller controllers for the ANGULARJS
- Angularjs a built-in service $http
Myapp.controller (' controller name ' function = data; }); $scope. Orderprop = ' age '; // sort default variable })
- Event handlers
<class= "btn btn-default" ng-click= "Testclick (' AA ')"> Click event </button>/* * * Click on the event note. Run () only $rootscope injected */function( param) { alert (param); }
ANGULARJS Service
' Use strict ';//define the angular module (only defined to be introduced as a dependency package in App.js)//Dependent Ngresource PackagevarServices = angular.module (' Services ', [' Ngresource ']);//. Factory () Factory mode, specifically not in-depth understanding of the study, temporarily follow the demo writeServices.factory (' Newsservice ', [' $resource ', ' $routeParams ', ' API ',//Controller Access handle function($resource, $routeParams, API) {return$resource (Api.url+ '/news/:action/:id ',//defining data Request URLs{ }, {getList: {method:' GET ', params:{action: ' Lists '},isarray:true}//News Model Method }); }]);
Filters for ANGULARJS filter filter
function () { // return filter method return function(input) { /// return filter result return input? ' \u2713 ': ' \u2718 '; }});
- Angularjs built-in filtering method
* {{"lower cap string" | uppercase}}
{{{foo: ' Bar ', baz:23} | json}}
{{1304375948024 | date}}
{{1304375948024 | date: ' YYYY-MM-DD HH:mm:ss '}}
{' abc ' |uppercase}}
Results:
Angularjs Getting Started finishing