2015-06-19 42 views
0

爲什麼ngController scheduleController沒有綁定到頁面。然而同樣是工作在this視頻(@ 29分鐘)爲什麼控制器沒有綁定到角應用變量

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" ng-app=""> 
<head> 
    <title></title> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" /> 
</head> 
<body ng-controller="scheduleController"> 
    <div class="container"> 
     <select ng-model="test" ng-options="schedule for schedule in scheduler.scheduleType"> 
     </select> 
     {{value}} 
    </div> 

    <script src="Scripts/angular.min.js"></script> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> 
     <script> 
      function scheduleController($scope) { 
       $scope.scheduler = { 
        scheduleType: ['One time', 'Daily', 'Weekly', 'Monthly' 
         , 'Monthly Relative', 'Yearly', 'Year long'] 
       }; 
       $scope.value = 'Shantanu'; 
      } 
    </script> 
</body> 
</html> 

我使用如果你採用了棱角分明的版本1.3或高達AngularJS V1.4.1

+0

你怎麼知道它不是約束? –

+0

當我使用nginit時,同樣的下拉菜單對我有用,但是當我將這段代碼移入控制器時停止了工作。看到我以前的問題 –

回答

1

,你有你的控制器手動註冊到您的應用程序。這意味着你不能有ng-app="",但你需要有,例如,ng-app="myApp",並且有:

var myApp = angular.module("myApp", []); 

myApp.controller("scheduleController", scheduleController); 
相關問題