Previous blog we installed and set up angular. In this blog I’ll do more practice with angular and code an app. With things properly in the html index file, we move onto the app.js code.
The first thing I did in the app.js is create a module for our TestApp we created in the markup.
This is similar to modules.exports It’s a named thing that contains code that doesn’t collude with other code. The empty array usually would a list of modules that are dependencies. It’s empty since it’s a simple app.
Then I made the TestApp find modules and do other things like .controller.
This new code adds a controller of this name, to this module, to this app, and executes this function. Then I called the controller function. It’ll be called by Angular itself.
Next I created a new message property to .this. Angular made a variable point to the same object that this variable here in app.js. In the previous blog in the HTML body ng-controller element. VM(view model) is a model or the data and properties methods that I want for this particular screen is going to be made available to the same object. So Angular will attach message inside HTML.
For the Angular message to reach inside of HTML message I created double set of curly braces with vm.message.