TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How To Use ng-view In AngularJS
Ajay Malik
Aug 22
2016
Code
795
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
<!DOCTYPE html
>
<
html
>
<
script
src
=
"http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"
>
</
script
>
<
script
src
=
"//ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"
>
</
script
>
<
body
ng-app
=
"myApp"
>
<
p
>
<
a
href
=
"#/"
>
Main
</
a
>
</
p
>
<
a
href
=
"#red"
>
Red
</
a
>
<
a
href
=
"#green"
>
Green
</
a
>
<
a
href
=
"#blue"
>
Blue
</
a
>
<
div
class
=
"ng-view"
>
</
div
>
<
script
>
var
app
=
angular
.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider
.when("/", {
templateUrl : "main.htm"
})
.when("/red", {
templateUrl : "red.htm"
})
.when("/green", {
templateUrl : "green.htm"
})
.when("/blue", {
templateUrl : "blue.htm"
});
});
</
script
>
<
p
>
Click on the links.
</
p
>
<
p
>
This example uses the ng-view directive as a class attribute to a DIV element.
</
p
>
</
body
>
</
html
>
AngularJS
Use ng-view