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啦,要不然就得报错了
时间: 2024-10-02 17:33:43