简体   繁体   English

AngularJS todoapp在网页中显示为变量名

[英]AngularJS todoapp displaying as the variable name in webpage

I'm following a tutorial online, but when I refresh my browser I get {{todo.title}} and the checkbox doesn't put a line through the text if clicked. 我正在在线学习教程,但是刷新浏览器后,我得到{{todo.title}},如果单击该复选框,则不会在文本中插入一行。 Any ideas why. 任何想法为什么。 I don't see anything different from my code and the video I'm following. 我没有看到与我的代码和正在观看的视频不同的内容。

<!doctype html>
<html lang="en" ng-app="ToDo">
   <head>
      <meta charset="UTF-8">
      <title>todo</title>
      <style>
         .done{text-decoration: line-through;color:#ccc;}
      </style>
   </head>
   <body>
      <div ng-controller='todoController'>
         <form name="frm" ng-submit="addTodo()">
            <input type="text" name = "newtodo" ng-model="newtodo" required>
            <button ng-disabled="frm.$invalid">Go</button>
         </form>
         <button ng-click="clearCompleted()">Clear Completed</button>
         <ul>
            <li ng-repeat="todo in todos">
               <input type="checkbox" ng-model="todo.done" />
               <span ng-class="{'done': todo.done}">{{todo.title}}</span>
            </li>
         </ul>
      </div>
      <script scr="bower_components/angular/angular.min.js"></script>
      <script> 
         angular.module('ToDo', []).
         controller('todoController', ['$scope', function($scope){
            $scope.todos = [{'title': 'Build a todo app', 'done':false}];
            $scope.addTodo = function(){};
            $scope.clearCompleted = function(){};
         }]);
      </script>
   </body>
</html>

您将src拼写错误为scr

 <script scr="bower_components/angular/angular.min.js"></script>

Please include angularjs file like below. 请包括如下所示的angularjs文件。 because u not included path of AngularJS Library 因为你没有包括AngularJS库的路径

<head>
<meta charset="UTF-8">
<title>todo</title>
<style>
.done{text-decoration: line-through;color:#ccc;}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM