First introduce JS file Angular.min.js,
Introduction of controller: Controllers. Js
Where multiple controllers can be defined: for example,
var Phonelistctrl = [' variable ', ' variable ', function (variable, variable) {
Assign values to variables in the layout, such as
$http. Get (XXX). Success (function (data) {
$scope. phones = data;
});
}];
var Phonedetailctrl = [' $scope ', ' $routeParams ', function ($scope, $routeParams) {
$scope. Phoneid = $routeParams. Phoneid;
}];
$scope: Variable objects in a layout file
$http: The object used to get the file
$routeParams: An object used to get a variable from a path.
In the layout:
ng-app= "Phonecat"
Import a map named Phonecat
<div ng-view></div>
View to import Ng
<select ng-model= "Orderprop" >
Select for search, match for Orderprop
<input ng-model= "Query" >
Input for search, match for query
<li>
ng-repeat= "Phone in phones" to traverse the phones variable and store it in the phone cell
Filter:query Matching Input Lookup
Orderby:orderprop Matching Select sort
<a>
href= "#/phones/{{phone.id}" this link is for app mapping
Ng-src= "{{Phone.imageurl}}" cannot be used with SRC, it is the loading of a picture after loading the page
App.js://define a map named Phonecat. config: Set
Angular.module (' Phonecat ', []).
Config ([' $routeProvider ', function ($routeProvider) {
$routeProvider. When ('/phones ', {templateurl: ' XXX ', Controller:phonelistctrl}).
When ('/phones/:p Honeid ', {templateurl: ' partials/phone-detail.html ', Controller:phonedetailctrl})
}]);