2

I am learning AngularJS and ended up with the following code for ToDoList basic app. I viewed it in a browser it didn't work. I am new to the Angular and mightn't get obvious things, so I thought if my app name is

todoApp

Then I should put

$scope.todoApp

instead of

$scope.todo

but turned out that's not an issue.

  <!DOCTYPE html>
  <html ng-app="todoApp">
  <head>
    <title>To DO List</title>
    <link href="bootstrap.css" rel="stylesheet">
    <link href="bootstrap-theme.css" rel="stylesheet>
    <script type="text/javascript" src="angular.min.js"></script>
    <script type="text/javascript">
         var model = {
             user: "Adam",
             items: [{ action: "Buy flowers", done: false },
                    { action: "Get Shoes", done: false },
                    { action: "Collect Tickets", done: true },
                    { action: "Call Joe", done: false }]
            };
         var todoApp = angular.module("todoApp", []);

         todoApp.controller("ToDoCtrl", function($scope) {
            $scope.todo = model;
          });
    </script>
  </head>
 <body ng-controller="ToDoCtrl">
   <div class="page-header">
     <h1>
        {{todo.user}}'s To Do List
        <span class="label label-default">{{todo.items.length}}</span>
     </h1>
   </div>
  <div class="panel">
    <div class="input-group">
        <input class="form-control" />
        <span class="input-group-btn">
            <button class="btn btn-default">Add</button>
        </span>
    </div>
    <table class="table table-striped">
        <thead>
            <tr>
                <th>Description</th>
                <th>Done</th>
            </tr>
        </thead>
        <tbody>
             <tr ng-repeat="item in todo.items">
                <td>{{item.action}}</td>
                <td><input type="checkbox" ng-model="item.done" /></td>
                <td>{{item.done}}</td>
             </tr>
          </tbody>
        </table>
     </div>
   </body>
</html>

That's what I get in a browser..enter image description here

And that's what I guess I am supposed to get...enter image description here

Why it doesn't work?

2
  • Any error in console?? You are missing " in style sheet. Commented Sep 25, 2015 at 16:05
  • 1
    SO try toDoApp instead Commented Sep 25, 2015 at 16:08

1 Answer 1

2

Your HTML getting invalid because you are missing " in link tag's rel attribute. Here you are missing:

<link href="bootstrap-theme.css" rel="stylesheet>
                                                ^ ==> missing "

Working DEMO /* updated css */

Have a look at Invalid HTML in DEMO. Here you can see after link tag HTML is colored green.

Sign up to request clarification or add additional context in comments.

1 Comment

Yep @AlexandraProdan. This is also important aspect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.