Assuming your controller is named FormController .
First step
The first step is to declare the route (or ng-controller value if you are not using a router) as such:
FormController as form
Due to the above configuration, angular will be an alias as form instances of FormController .
HTML template
Then adapt your html template according to the alias (form) you provided. I modified your html to save only the essential part of the question. We call the form.reply and form.close .
<a href="#" ng-click="form.reply()">REPLY</a> <a href="#" ng-click="form.close()">CLOSE</a>
Controller declaration
In accordance with what we wrote above, our controller should look like this:
myApp.controller('FormController', function () { var vm = this; vm.reply = function () {
Pay attention to the line var vm = this; ? Theoretically, we could get rid of this line and save the reply and close functions in the this object. But depending on the context, this does not apply to the same object. In the callback function, this will not refer to the controller, but to the callback function. This is why we cache this , which refers to the controller. We usually call this vm link for the viewmodel, because the controller controls the view.
source share