59
rated 0 times
[
65]
[
6]
/ answers: 1 / hits: 64727
/ 12 Years ago, fri, january 18, 2013, 12:00:00
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
firstMethod
fromsecondMethod
? 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.
More From » angularjs