The Angularjs of today's study

Source: Internet
Author: User

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})
}]);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.