Angular ng-view Directive

What is an ng-view Directives?

The “ng-view” directive is used to switch between views in AngularJs.

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Angular Demo</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular-route.min.js"></script>
    <script >
        var myApp = angular.module("AngularApp",['ngRoute']);
        myApp.config(['$routeProvider',
            function ($routeProvider) {
                $routeProvider.when('/', {
                    templateUrl: 'test.html',
                    controller: 'testCtrl'
                })
            }
        ]);
        myApp.controller("testCtrl", function($scope){
            $scope.model = {
                text:"This is the example of ng-view in angular js"
            }
        });
    </script>
</head>

<body ng-app="AngularApp">
<ng-view></ng-view>
</body>
</html>

The live view,

About Blogger

ANIL SINGH

Hey! I am Anil Singh. I am Active Blogger, Writer and Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
http://www.code-sample.com
http://www.code-sample.xyz

    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment

SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book