Posts

Showing posts from March, 2018

More Features on Angular

Image
As I promised in my previous post, today I am going to talk about how to declare scope variable and bind the variables to the view. Here we are going to use the $scope object to communicate with our view. The $scope variable allows us to tell our HTML that there is a value in our controller that needs to be displayed in the HTML. Here also I take the example that I talked about in my previous post. So, let's see how to do it.  Open menuController.js file and inside the main function ($scope) method, to create a property named "title" enter the following code.                                          $scope.model = {title: 'Our Menu'}; In index.html file  Inside the <h2> tag, to display the title variable that you just defined inside your controller rather than static text, replace the contents of the  <h2>  tag with  {{model.title}} . It is best practice to always bind to an object off of the scope, in this case, "model". T