2016-09-07 40 views

回答

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/),这样就可以很容易理解。

但是,如果你想扩展与其他图书馆角度的功能,那么你需要包括那些依赖,就像你说的答复

+0

感谢拉胡尔。我想添加bootstrap和另一个dependency.it是手动添加或添加任何包管理器的最佳方式。 –

+0

@BharatDangar对我的例子,如果你想添加bootstrap然后使用:angular.module('todoApp',[])>>> angular.module('app',['ui.bootstrap'])我会建议阅读此答案:http://stackoverflow.com/a/22422096/1960558。总是阅读文档:http://angular-ui.github.io/bootstrap/ –