ng-init是給angular執行給定的表達式,初始化變數的值 這樣就初始化了myTest的值,ng-app沒有設值,要是設置的話,就要js啦,要不然就得報錯了 ...
ng-init是給angular執行給定的表達式,初始化變數的值
<!DOCTYPE html> <html> <head> <meta charset='UTF-8'> <title>ng-init</title> <script type="text/javascript" src='static/plugins/angular.min.js'></script> </head> <body> <div ng-app='' ng-init='myTest="hello world"'> {{myTest}} </div> </body> </html>
這樣就初始化了myTest的值,ng-app沒有設值,要是設置的話,就要js啦,要不然就得報錯了