Home > Web Front-end > JS Tutorial > AngularJS Basics_AngularJS

AngularJS Basics_AngularJS

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:25:23
Original
1017 people have browsed it

angularJS definition and features

1.google front-end open source framework

2. MVVM (model view view-model) design pattern: Model will interact with ViewModel (through $scope object) and will monitor changes in Model. These can be sent and rendered via View, using HTML to display your code

3. Convenient REST

4. Data binding and dependency injection

5. You can operate HTML just like XML. AngularJS completes related settings through its own compiler and directives

6. Templates are passed to the Angular compiler as DOM elements

7.AngularJS extends HTML through directives and binds data to HTML through expressions.

Build angularJS application

Add Angular's <script> tag to the <head> tag </p> <p></p> <div class="codetitle"> <span><a style="CURSOR: pointer" data="63312" class="copybut" id="copybut63312" onclick="doCopy('code63312')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code63312"> <br> <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular.min.js"></script>

Add ng-app directive to tag

Copy code The code is as follows:

ng-app="guetonline"
ng-controller="MainController"
>

Create new directory script and app.js files, define and configure all modules and dependencies in app.js

Copy code The code is as follows:

var app = angular.module('guetonline', [
'ngRoute',
'mobile-angular-ui',
'mobile-angular-ui.gestures'
]);

Define controllers, services, and instructions in the module app

Copy code The code is as follows:

app.controller( 'MainCtrl', function( $rootScope, $scope, $http ) {} ) //Controller
app.service( 'MainSevicel', function() {} ) //Service
app.directive( 'dragToDismiss', function() {} ) //Directive

Define routes in module app

Copy code The code is as follows:

app.config(function($routeProvider) {
$routeProvider.when('/', {templateUrl: 'index/home', reloadOnSearch: false});
$routeProvider.when('/scroll', {templateUrl: 'scroll.html', reloadOnSearch: false});
$routeProvider.when('/toggle', {templateUrl: 'toggle.html', reloadOnSearch: false});
$routeProvider.when('/tabs', {templateUrl: 'tabs.html', reloadOnSearch: false});
$routeProvider.when('/accordion', {templateUrl: 'accordion.html', reloadOnSearch: false});
$routeProvider.when('/overlay', {templateUrl: 'overlay.html', reloadOnSearch: false});
$routeProvider.when('/forms', {templateUrl: 'forms.html', reloadOnSearch: false});
$routeProvider.when('/dropdown', {templateUrl: 'dropdown.html', reloadOnSearch: false});
$routeProvider.when('/drag', {templateUrl: 'drag.html', reloadOnSearch: false});
$routeProvider.when('/carousel', {templateUrl: 'carousel.html', reloadOnSearch: false});
$routeProvider.when('/news/official_view', {templateUrl: '/news/official_view', reloadOnSearch: false});
});

To be continued. . Next step is to learn more about 4.5 steps and filters

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
angular.js - angularJS ng-style用法
From 1970-01-01 08:00:00
0
0
0
angular.js - AngularJS form validation
From 1970-01-01 08:00:00
0
0
0
angular.js - Learning AngularJS
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template