1)弄一个ng-app(angularjs 应用)

2)在里面用ng-model(angularjs 模型)就可以定义一个模型变量

3)使用模版方法就可以输出变量了(例如:{{name}})

 

示例:

 

<!DOCTYPE html>
<html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script>
<body>

<p>Try to change the names.</p>

<div ng-app="">

<p>Name: <input type="text" ng-model="name"></p>
<p>You wrote: {{ name }}</p>

</div>

</body>
</html>

 

 

注:ng-app 一定要空的,如果有值,变量的操作就托管给js了,要js里用angularjs的控制器才能控制

相关文章:

  • 2021-06-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
猜你喜欢
  • 2021-06-21
  • 2022-12-23
  • 2021-10-28
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案