困惑的设置angularjs.Many依赖发现

时间:2016-09-07 06:33:44

标签: angularjs

我谷歌设置angularjs.I发现很多教程,但我很困惑。我找到了

  1. angular-seed
  2. 约曼
  3. 亭子
  4. 有必要使用此依赖项。 开始angularjs有任何划痕。

1 个答案:

答案 0 :(得分:0)

对于Angularjs,您不需要任何依赖。只是包含angularjs库(如jquery或任何其他库)。看看这里:

<!doctype html>
<html ng-app="todoApp">
<head>
<script  src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script src="todo.js"></script>
<link rel="stylesheet" href="todo.css">
</head>
<body>
<h2>Todo</h2>
<div ng-controller="TodoListController as todoList">
  <span>{{todoList.remaining()}} of {{todoList.todos.length}} remaining</span>
  [ <a href="" ng-click="todoList.archive()">archive</a> ]
  <ul class="unstyled">
    <li ng-repeat="todo in todoList.todos">
      <label class="checkbox">
        <input type="checkbox" ng-model="todo.done">
        <span class="done-{{todo.done}}">{{todo.text}}</span>
      </label>
    </li>
  </ul>
  <form ng-submit="todoList.addTodo()">
    <input type="text" ng-model="todoList.todoText"  size="30"
           placeholder="add new todo here">
    <input class="btn-primary" type="submit" value="add">
  </form>
 </div>
 </body>
</html>

您的app.js包含angularjs代码:

angular.module('todoApp', [])
.controller('TodoListController', function() {
 var todoList = this;
 todoList.todos = [
  {text:'learn angular', done:true},
  {text:'build an angular app', done:false}];

 todoList.addTodo = function() {
  todoList.todos.push({text:todoList.todoText, done:false});
  todoList.todoText = '';
 };

 todoList.remaining = function() {
  var count = 0;
  angular.forEach(todoList.todos, function(todo) {
    count += todo.done ? 0 : 1;
  });
  return count;
 };

 todoList.archive = function() {
  var oldTodos = todoList.todos;
  todoList.todos = [];
  angular.forEach(oldTodos, function(todo) {
    if (!todo.done) todoList.todos.push(todo);
  });
 };
 });

(我从https://angularjs.org/获取此示例),以便您可以轻松理解。

但是如果你想扩展其他库的角度功能,那么你需要包含那些依赖,就像你说的那样