0

How can I achieve below given code correctly in angular js, here I want to execute loader method and initialize some variables.

ng-init="loader()" data-ng-init="firstName='John'"

1 Answer 1

4
 ng-init="loader(); firstName = 'John'"

But ng-init should almost always never used. Just move these instructions to your controller:

app.controller('MyController', function($scope) {
    // ...

    loader();
    $scope.firstName = 'John';
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.