-2

How to pass scope variable in ng-init using AngularJS

1
  • I'm voting to close this question as off-topic because: I don't understand this is question or answer, also the questioner is a human or Animal? Commented Nov 29, 2016 at 8:52

2 Answers 2

1

It can be done easily as shown below:

<div ng-init="data = 'This is initialized in ng-init'">
    Variable - {{data}}
</div>

Refer the demo here

Sign up to request clarification or add additional context in comments.

Comments

0

Try this Code

$scope.test = '10';

<div ng-controller = "controller" ng-init="test">

or

<div ng-controller="controller" ng-init="test = test">

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.