I'm a beginner in angularjs with a few questions about controllers.
Here's my example controller:
function exampleController($scope)
{
$scope.sampleArray = new Array();
$scope.firstMethod = function()
{
//initialize the sampleArray
};
$scope.secondMethod = function()
{
this.firstMethod();
};
};
Here are my questions:
- How I can call
firstMethodfromsecondMethod? Is the way I did it correct, or is better way? - How I can create a constructor for the controller? I need to call the secondMethod that call the firstMethod that initialize the sampleArray?
- How I can call a specific method from html code? I found ng-initialize but I can't figure out how to use it.