这是我的js文件的路径:
var app = angular.module('WebApp', ['ngRoute']);
/**
* Configure the Routes
*/
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider
// Home
.when("/", { templateUrl: "partials/kalendar.php", controller: "Ctrl" })
.when("/logout", { templateUrl: "partials/logout.php", controller: "PageCtrl" })
.otherwise({
controller: function() {
window.location.replace('/');
},
template: "<div></div>"
});
}]);
/**
* Controls all other Pages
*/
app.controller('PageCtrl', function ($scope) {
console.log("Page Controller reporting for duty.");
});
/**
* Controls calendar view
*/
app.controller('Ctrl', function ($scope) {
console.log("Controller reporting for duty.");
$scope.updateDuration = function() {
alert($scope.dateIn);
}
});
这是我kalendar.php的一部分:
<div>
<label>Datum:</label>
<div class="input-group input-append date">
<input type="text" class="span2 form-control" ng-model="dateIn">
<span class="input-group-addon">
<span class="glyphicon glyphicon-th-large"></span>
</span>
</div>
</div>
当我运行我的程序,页面控制器被调用(“Controller reporting for duty。”show in console),但是警告不起作用,因为$ scope.dateIn是未定义的。请帮我找到我的错误。
你没有调用'updateDuration()',alert语句将如何执行? – anoop