Angularjs Getting Started

Source: Internet
Author: User

Angularjs Getting Started

What is Angularjs

AngularJS Is a modern the JavaScript framework from Google commonly used to work with single Page applications (SPAs). AngularJS is open sourced under MIT License and the development progress of AngularJS can followed on its GitHub re Pository. The library is called Angular because HTML uses Angular brackets.

AngularJS is isn't a DOM manipulation library like jquery but it uses a subset of jquery called Jqlite. AngularJS is primarily based on declarative HTML attributes so can add to your HTML tags. You can try AngularJS in your browser using the Code School website.

Version 1.3.x is the current stable version and the Angular team are working towards a big rewrite of AngularJS for V2.0 wh Ich is currently still in development. This article focuses in Angular 1.X with some notes on where Angular are heading with 2.0.

How to use

New Project

Project structure

Installation

Open Bower.js, add dependencies

" Angular":"1.3.15",

Using gulp, generate files in the Wwwroot/lib directory:

In Gulpfile.js, add the following:

In the task run manager, run:

To add a reference to the _layout.cshtml:

Component

Directives

Add directives.cshtml:

To add a method in HomeControl.cs:

Access:

/home/directives

Https://docs.angularjs.org/api/ng/directive

DataBinding

HomeController.cs

Run:

Templates

HomeController.cs

Operation Result:

Update your changes in real time.

Expressions

Run results

Repeaters

Run results

$scope

Learn more on Scopes in AngularJS

Models

Defined:

var personapp = angular.module (' Personapp ', []);

Use:

<bodyng-app="personApp">

Controllers

Defined:

Use:

Services

Use Services

Run results

Using services to talk to a REST endpoint

To create a new file under the Wwwroot/app directory:

Personapp.js

Personfactory.js

Personcontroller.js

New model

New PersonController

New View

Run results

John Papa ' s Angular Style Guide

Routing and multiple views

Installation of Angular-route:

1, add support for Angular-route in Gulpfile.js.

2. Run the task Manager.

3 to see if the wwwroot/lib is generated.

Use
    1. New Personmodule.js

2, new personroutes.js

3, new personlist.html,persondetail.html

4, New personlistcontroller.js, Persondetailcontroller.js

5 , New View route.cshtml

PersonController.cs added in:

Run results

Code:

Https://github.com/aspnet/Docs/tree/master/aspnet/client-side/angular/sample/src

Event handlers

    1. New Eventhandlercontroller.js

    1. New View event.cshtml

Add in 3,personcontroller.cs

Operation Result:

Clicking on the Say Name button will pop up the box.

Angular 2.0

The next version.

Related resources:

    • Angular Docs
    • Angular 2 Info

Angularjs Getting Started

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.