Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is MVC architecture in Angular JS

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 332
    Comment on it

    MVC is Model-View-Controller architecture designed for web development. It has three main parts:
    In angular the way we organize things is different from the others in javascript.

    Model: Model contains all the information that is responsible for maintaining data. It gets the request from view and responds on it and also gets instructions from the controller to update itself. It is the lowest level of pattern in MVC architecture. It is data that can be static or dynamic. We can define some data or get it from some database or from some JSON file.
    Following code shows how we can create a model:

    $scope.cars = {
        first : ALTO,
        second : SWIFT
    }


    In the above example scope is an object, cars is a variable that is added to the scope and inside the curly brackets there is static JSON data.

    View: It displays a presentation of data to the user in some specific format. All the process of showing the data in the view is triggered by the controller. It is the display of data that we get from model. It is written inside double curly brackets like the following:
     

    {{<h2>cars.first</h2>}}

    Controller: It is a code that maintains the data between model and view. It gives response to the user and performs some action on the data. It controls how data is retrieved and displayed to the user. We can use it like following:

    function vehicle($scope){
    //add model data here
    }

    Now add a div around the view like this:
     

    <div ng-controller=vehicle></div>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: