Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Contributor: Ravishankar ChavarePart 4- MVC AngularJS controller defined in another file
#1
As we Already know the basic of MVC architecture of AngularJS. If you doesn't know how to MVC work read tutorial Here


You need 3 files two are

1.index.html
2.appcode.js

and one angular.min.js




1.index.html
Code:
        <!DOCTYPE html>
            <html ng-app="myApp">
            <head>
                <title>mvc</title>
                <script src="../angular.min.js"></script> //give path of the angular.min.js where it plced in local system
                <script src="appcode.js"></script>
            </head>
            <body>
                <p>Show Model data in View through Controller</p>
                <div ng-controller="myController">
                    Name:{{person.name}}
                    <br>
                    Mobileno:{{person.mobile}}
                </div>
            </body>
            </html>


2.appcode.js
Code:
var app=angular.module("myApp",[]);
    app.controller("myController",function($scope){
        $scope.person={
            'name':'ravi',
            'mobile':'123456789'
        }
    });

If you any problem comment that problem


Part 3-MVC in AngularJS
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)