NG-应用程序放置在html标签 [英] Place of ng-app in html tags

查看:147
本文介绍了NG-应用程序放置在html标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来AngularJS。我说,讲师NG-应用程序可以在HTML,身体,用div标签等我的问题是,如果异常,应用程序可以在HTML标签和body标签使用,有没有,如果我在html标记使用它,而不是身体标记任何使用?
我的意思是,头部标签是身体和HTML的中间。是否有头标记任何影响的原因,当我使用它的HTML标记或没有。希望我的问题是清楚的。

I'm new to AngularJS. My lecturer said ng-app can use in html, body, div tags etc. My question is, if ng-app can use in html tag and body tag, is there a any use if i use it in html tag rather than body tag? What I mean is, the head tag is middle of body and html. Is there any effect cause in head tags when I use it html tag or not. hope my question is clear.

推荐答案

,你会放置在身体标记的HTML标签内的NG-应用的原因是因为你要处理的头机身采用angularjs里面的东西。下面是一个例子:

The reason that you would place the ng-app inside the html tag over the body tag is because you want to manipulate something inside of the head and body using angularjs. Here is an example:

<html ng-app="MyApp">
<head>
  <meta charset="utf-8">
  <title ng-bind="'Title - ' + title"></title>
  <link rel="stylesheet" href="/css/style.css" />
</head>
<body>
...

在标题通知我有一个NG绑定,这样我可以使用的变量名称标题来改变网页的标题用户上。标题将永远是冠军 - 什么都链接他们对在我做标题app.js VAR的全球变量。这仅仅是一个理由把NG-应用HTML标记,而不是身体。

Notice in the title I have a ng-bind, this way i can use the variable name title to change the title of the web page the user is on. The title will always be Title - what ever link their on In the app.js I make the title var a global variable. This is just one reason to put ng-app in the html tag instead of body.

这篇关于NG-应用程序放置在html标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆