0

これはこれは私がスコープ変数を定義しているコントローラ私のアプリのHTML

<div class="todo"> 
     <div class="todo_column"> 
     <div style="font-weight:700; padding:15px;text-align:center;border-radius:5px 0 0 0;"> 
      <button ng-click="add = true;todo=false" class="ui button"> 
      <i style="color:#fff;" class="add square icon"></i> 
      Add 
      </button> 
     </div> 
     <ul> 
      <li ng-click="detail(todo)" ng-repeat="todo in todos track by $index"> 
      <h3>{{ todo.title }}</h3> 
      <h6>{{ todo.note_date }}</h6> 
      </li> 
     </ul> 
     </div> 
     <div class="todo_full"> 
     <div class="todo_title"> 

      <h1> 
      <span ng-show="todo">{{ title }}</span> 
      <input ng-show="add" class="input_title" type="text" placeholder="Title" ng-model="newTitle"/> 
      <input ng-show="editing" class="input_title" type="text" value="{{ title }}"/> 
      </h1> 

      <span class="check"> 
      <i style="font-size:2em;" ng-show="todo" class="square outline icon"></i> 
      <i class="write square icon" ng-show="todo" ng-click="todo=false;editing=true" style="font-size:2em;"></i> 
      <i class="check square icon" ng-show="{{ todo.complete }}" style="font-size:2em;"></i> 
      <i class="add square icon" ng-show="add" ng-click="newEntry()" style="font-size:2em;"></i> 
      <i class="check square icon" ng-show="editing" ng-click="editing=false;todo=true;" style="font-size:2em;padding-top:0;"></i> 
      </span> 
     </div> 

     <h4>Note:</h4> 

     <p ng-show="todo" class="todo_note">{{ note }} 
     </p> 

     <textarea ng-show="add" class="todo_note" placeholder="Take a note" rows="20" ng-model="newNote"></textarea> 

     <textarea ng-show="editing" class="todo_note" placeholder="Take a note" value="{{ note }}" rows="20"></textarea> 


     </div> 
    </div> 

ですnewTodo

var main = angular.module("mainPage",['ngRoute']); 
var app = angular.module("appPage",["ngRoute"]); 

main.config(function($routeProvider){ 
    $routeProvider 
    .when("/", { 
    templateUrl: "routes/main.html" 
    }) 
    .when("/signup",{ 
    templateUrl: "routes/signup.html" 
    }); 
}); 

app.config(function($routeProvider) { 
    $routeProvider 
    .when("/", { 
    templateUrl : "routes/todo.html" 
    }) 
    .when ("/setting", { 
    templateUrl: "routes/setting.html" 
    }); 
}); 

app.controller("appController", function ($scope) { 
    $scope.add = true; 
    $scope.newTodo = { 
    title:"", 
    note:"", 
    note_date:"", 
    complete:false 
    }; 

    $scope.todos = [ 
    {title: "Call Vaibhav", note: "", note_date: "", complete: false}, 
    {title: "Grocery", note: "Lemons, Apple and Coffee", note_date: "", complete: false}, 
    {title: "Website design for Stallioners", note: "UI/UX on [email protected]", note_date: "", complete: false}, 
    {title: "Fill MCA form", note: "First search for all the colleges", note_date: "", complete: false } 
    ]; 

    $scope.newEntry = function() { 
    $scope.newTodo.title = $scope.newTitle; 
    $scope.newTodo.note = $scope.newNote; 
    $scope.newTodo.note_date = Date.now(); 
    $scope.add=false; 
    $scope.todo=true; 
    $scope.todos.unshift(newTodo); 
    console.log(newTodo); 
    $scope.newTodo = { 
     title:"", 
     note:"", 
     note_date:"", 
     complete:false 
    }; 
    }; 

    $scope.detail = function (todo) { 
    $scope.title = todo.title; 
    $scope.note = todo.note; 
    $scope.todo=true; 
    $scope.add=false; 
    $scope.editing=false; 
    }; 

}); 

// app.service("todos", function($http){ 
// $http.get("mockdata/todos.json") 
// }); 

新機能ではありません関数内で取ったnewTodo変数を取ることができますが、パラメータとしてではなくコンソールはng-repeat dupesに応答しました

+0

あなたは解決策を見つけましたか? – Sajeetharan

+0

yupは関数のパラメータとして変数を取ります。愚かな間違い –

答えて

0

2つのモジュールを宣言する必要はありません。

var app = angular.module("appPage",["ngRoute"]); 
app .config(function($routeProvider){ 
}