-2

I google for setup angularjs.I found many tutorial but i am confused.I found

  1. angular-seed
  2. Yeoman
  3. bower
  4. etc.

it is necessary to use this dependency. there is any scratch for start angularjs.

Bharat Dangar
  • 527
  • 4
  • 20

1 Answers1

0

For Angularjs you don't need any dependency. Just to include angularjs library (like jquery or any other library). Have look here:

<!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>

And your app.js which contains angularjs code:

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);
  });
 };
 });

(I took this example from https://angularjs.org/ ) so that you can understand easily.

But if you want to extend angular functionality with other library then you need to include those dependency, like you said

Ruhul Amin
  • 1,751
  • 15
  • 18
  • Thanks rahul for reply. i want to add bootstrap and another dependency.it is best way to add that manually or add by any package manager. – Bharat Dangar Sep 07 '16 at 06:58
  • @BharatDangar on my example if you want to add bootstrap then use: angular.module('todoApp', []) >>> angular.module('app', ['ui.bootstrap']) I would to recommend to read this answer: http://stackoverflow.com/a/22422096/1960558 . Always read documentation: http://angular-ui.github.io/bootstrap/ – Ruhul Amin Sep 07 '16 at 10:42