简体   繁体   中英

Angular JS ng-init not working

I am absolutely new to angular js. I am trying to build a simple app. I am testing the site on wamp server. For some reason, the ng-init directive isn't working. Could anyone please help? Also, angular material elements are not displaying. Code is below:

<body ng-app="ngTest" ng-init="message='Hello'">
<h1>{{message}}</h1>
</body>

Upon running all that is showing is:

<body ng-app="ngTest" ng-init="message='Hello'">
<h1>{{message}}</h1>

You need to specify both the application (via ng-app) as well as the controller (via "ng-controller"). You also need to include the js files for AngularJS as well as the JS file containing your declaration of your control (via the scripts section).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM