我创建了index.html,如下所示:
<html lang="en" ng-app="bootProject" >
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>SASS / Home
</title>
<script src="../../node_modules/angular/angular.min.js"></script>
<script src="../../node_modules/angular-route/angular-route.min.js"></script>
<!-- Bootstrap core CSS -->
<link href="../../node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="../../dist/css/main.css" rel="stylesheet">
<!-- Custom styles for font-awesome css -->
<link href="../../node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<div ng-view></div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../../node_modules/jquery/dist/jquery.js"></script>
<script src="../../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
angular-route.min.js
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../javascript/main.js"></script>
<script src="//localhost:35729/livereload.js"></script>
</body>
</html>
有一个带有导航栏的“home.html”,我想点击“登录”标签,然后进入“log.html”页面。
<ul class="nav navbar-nav">
<li class="active"><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#service">Services</a></li>
<li><a href="#blog">Blog</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
<ul class="nav navbar-nav pull-right">
<li><a href="#register">Register</a></li>
<li><a href="#log">Login</a></li>
<div><ng-view></div>
</ul>
</div>
这是我的“main.js”:
// Module
var weatherApp = angular.module('bootProject',['ngRoute']);
// Route
weatherApp.config(function($routeProvider){
$routeProvider
.when('/home',{
templateUrl:'http://localhost:1337/dist/templates/home.html',
controller: 'homeController'
})
.when('/log',{
templateUrl:'http://localhost:1337/dist/templates/log.html',
controller: 'logController'
})
.when('/dashboard',{
templateUrl:'http://localhost:1337/dist/templates/home.html',
controller: 'dashboardController'
});
});
//Controllers
weatherApp.controller('logController', [ '$scope', '$location',function($scope,$location){
$scope.submit= function(){
var uname = $scope.username;
console.log(uname);
var pass = $scope.password;
if($scope.username =='admin' && $scope.password =='admin'){
$location.path("/dashboard");
}
};
}]);
当我在localhost / dist中打开我的项目时,它只向我显示了一行“angular-route.min.js”,但当我在localhost / src中打开它时,它显示了正确的页面,但我仍然可以看到log.html页面中的那一行。
请告诉我我的错误是什么?
答案 0 :(得分:0)
我的路由中没有看到<?php
// Simple PHP Upload Script: http://coursesweb.net/php-mysql/
$uploadpath = 'uploads/'; // directory to store the uploaded files
$max_size = 5000; // maximum file size, in KiloBytes
$alwidth = 6000; // maximum allowed width, in pixels
$alheight = 6000; // maximum allowed height, in pixels
$allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png'); // allowed extensions
if(isset($_FILES['fileup']) && strlen($_FILES['fileup']['name']) > 1) {
$uploadpath = $uploadpath . basename( $_FILES['fileup']['name']); // gets the file name
$sepext = explode('.', strtolower($_FILES['fileup']['name']));
$type = end($sepext); // gets extension
list($width, $height) = getimagesize($_FILES['fileup']['tmp_name']); // gets image width and height
$err = ''; // to store the errors
// Checks if the file has allowed type, size, width and height (for images)
if(!in_array($type, $allowtype)) $err .= 'The file: <b>'. $_FILES['fileup']['name']. '</b> not has the allowed extension type.';
if($_FILES['fileup']['size'] > $max_size*1000) $err .= '<br/>Maximum file size must be: '. $max_size. ' KB.';
if(isset($width) && isset($height) && ($width >= $alwidth || $height >= $alheight)) $err .= '<br/>The maximum Width x Height must be: '. $alwidth. ' x '. $alheight;
// If no errors, upload the image, else, output the errors
if($err == '') {
if(move_uploaded_file($_FILES['fileup']['tmp_name'], $uploadpath)) {
echo 'File: <b>'. basename( $_FILES['fileup']['name']). '</b> successfully uploaded:';
echo '<br/>File type: <b>'. $_FILES['fileup']['type'] .'</b>';
echo '<br />Size: <b>'. number_format($_FILES['fileup']['size']/1024, 3, '.', '') .'</b> KB';
if(isset($width) && isset($height)) echo '<br/>Image Width x Height: '. $width. ' x '. $height;
echo '<br/><br/>Image address: <b>http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$uploadpath.'</b>';
}
else echo '<b>Unable to upload the file.</b>';
}
else echo $err;
}
?>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<![endif]-->
<title>SendIT / Free image Upload</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--style sheets-->
<link rel="stylesheet" href="css/filoxenia.css">
<link rel="stylesheet" href="css/magnific-popup.css">
<link rel="stylesheet" href="css/custom.css">
<script src="js/vendor/custom.modernizr.js"></script>
<style>
.wrap{
width: 700px;
margin: 10px auto;
padding: 10px 15px;
background: white;
border: 2px solid #DBDBDB;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
text-align: center;
overflow: hidden;
}
#preview {
color: red;
}
#preview img{
margin-top: 30px;
max-width: 100%;
border: 0;
border-radius: 3px;
-webkit-box-shadow: 0px 2px 7px 0px rgba(0, 0, 0, .27);
box-shadow: 0px 2px 7px 0px rgba(0, 0, 0, .27);
overflow: hidden;
}
input[type="submit"]{
background-color: red;
border: 0;
color: white;
font-weight: bold;
font-style: italic;
padding: 6px 15px 5px;
cursor: pointer;
}
</style>
</head>
<body>
<header class="contain-to-grid">
<div class="row">
<div class="large-12 column">
<nav id="menu" class="top-bar">
<ul class="title-area">
<li class="name">
<a href="index.html">
<img src="images/logo.png" alt="logo">
</a>
</li>
<li class="toggle-topbar menu-icon"><a href="#"><span>Menu</span></a>
</li>
</ul>
<section class="top-bar-section">
<ul class="right">
<li><a href="plans.html">Home</a>
</li>
<li><a href="features.html">PLANS & PRICING</a>
</li>
<li><a href="terms.html">Terms</a>
</li>
<li id="signup"><a href="login.php" class="button no-margin">Login</a>
</li>
</ul>
</section>
</nav>
</div>
</div>
</header>
<section id="main" role="main">
<div class="breadcrumb-container">
<div class="row">
<div class="large-12 column">
<nav class="breadcrumbs animated bounceInDown">
<a href="index.html">Home</a>
<a class="current" href="#">Upload</a>
</nav>
</div>
</div>
</div>
<section class="part">
<div class="wrap">
<p>Valid formats: jpeg, gif, png, Max upload: 4mb (Free Users)</p>
<!-- simple file uploading form -->
<form id="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<input type="file" accept="image/*" name="fileup" />
<input id="button" type="submit" value="Upload">
</form>
</div><!--wrap-->
<div id="space"></div>
</section>
</section>
<style>
#space {
padding-top: 450px;
}
</style>
<a id="back-top" href="#"><i class="icon-caret-up"></i></a>
<footer>
<div class="row">
<p class="small-12 large-4 large-uncentered column copyright">
Copyright © 2015 SendIT All Rights Reserved.
</p>
<p class="small-12 large-8 column social">
<a href="mailto:info@filoxenia.com"><i class="icon-envelope"></i></a>
<a href="#"><i class="icon-rss"></i></a>
<a href="//www.facebook.com" target="_blank"><i class="icon-facebook"></i></a>
<a href="//www.twitter.com" target="_blank"><i class="icon-twitter"></i></a>
<a href="//www.google.com/plus" target="_blank"><i class="icon-google-plus"></i></a>
<a href="//www.linkedin.com" target="_blank"><i class="icon-linkedin"></i></a>
<a href="skype:echo123?call" target="_blank"><i class="icon-skype"></i></a>
</p>
</div>
</footer>
<!-- Javascript -->
<!-- jQuery Library-->
<script type="text/javascript" src="js/vendor/jquery.form.js"></script>
<script type="text/javascript" src="js/vendor/script.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="js/vendor/jquery.magnific-popup.js"></script>
<script src="js/foundation/foundation.js"></script>
<script src="js/foundation/foundation.topbar.js"></script>
<script src="js/foundation/foundation.section.js"></script>
<script src="js/filoxenia.js"></script>
<script src="js/custom.js"></script>
</body>
</html>
。您应该使用.otherwise
来捕获与您指定的路由不匹配的路由。
.otherwise