绑定数据有两种方式:

<!DOCTYPE html>
<html ng-app>
<head>
  <title>2.2显示文本</title>
  <meta charset="utf-8">
  <script src="../angular.js"></script>
  <script src="script.js"></script>
</head>
<body>
  <div>
    <div ng-controller="showText" >
      <h1 ng-bind="text.message"></h1>
      <h1>{{text.name}}</h1>
    </div>
  </div>
</body>
</html>

1:ng-bind = "变量"

2:{{变量}}

ng-bind属性来绑定数据和{{}}来绑定数据,效果一致,
但是如果有大量的数据,在数据还没有加载完成之前,如果使用{{}},用户会看到{{}},而不是被替换掉的实际数据.所以初始化的数据可以使用ng-bind

 

相关文章:

  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2021-08-22
猜你喜欢
  • 2021-05-02
  • 2022-12-23
  • 2022-12-23
  • 2021-06-26
  • 2021-07-19
  • 2021-10-02
  • 2022-12-23
相关资源
相似解决方案