2. Use ng-init to Set Default Values in Your HTML
Inside the body, where you want to initialize your variable:
Here, username is set to 'Guest' and age is set to 25 by default.
3. Display the Variables in Your Template
You can display these initialized variables anywhere within the scope using AngularJS bindings:
Welcome, {{ username }}!
Your age is {{ age }}.

Leave a Reply