[英]How to display different pages with angular view and routing?
我有两个html文件,我需要使它们以角度显示。
这是我的js:
var app = angular.module('test', ['ui.bootstrap','ngRoute']);
app.controller('submitController', ['$scope','$http','$timeout',function($scope, $http, $timeout) {
$http.get('podaci.json').success(function(data) {
$scope.data = data;
$scope.counter = $scope.data.vreme;
});
$scope.countdown = function() {
$timeout(function() {
if( $scope.counter > 0 ){
$scope.counter--;
}
/* else
go to the other page */
$scope.countdown();
}, 1000);
};
$scope.answers = [];
$scope.text = '';
$scope.submit = function() {
if ($scope.text) {
$scope.answers.push(this.text);
$scope.text = '';
}
};
$scope.remove = function($index) {
$scope.answers.splice($index, 1);
}
}]);
app.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/', {
templateUrl: 'templates/quiz.html',
controller: 'SubmitController'
}).
when('/result', {
templateUrl: 'templates/result.html',
controller: 'ResultController'
}).
otherwise({
redirectTo: '/'
});
}]);
这是quiz.html,第二个html为空:
页面上有一个计时器,当时间到时,应该转到另一页。 或者当您单击我还没有点击的按钮时。 但是我无法显示第二页。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.