我是使用angularjs的新手,并且很难有角度路线到新页面加载。基本上我想弄清楚如何在页面之间移动以构建多页面应用程序,但即使我已经创建了模块,我仍然收到此错误。
模块' login.html'不可用!您要么错误拼写了模块名称,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。
这些是我的index.html和我的app.js文件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-
scalable=no, width=device-width">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the
CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
</head>
<body>
<div ng-app='login.html'>
<ion-nav-view></ion-nav-view>
</div>
</body>
</html>
app.js文件:
// Ionic Starter App
var app = angular.module('ionicApp', ['ionic'])
app.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/')
$stateProvider.state('login', {
url: '/',
templateURL: 'login.html'
})
})
的login.html
<ion-view title=""id="welcome-view" hide-nav-bar="true">
<ion-content>
<div class="logo-welcome"></div>
<div class="login-btns">
<div id="social-links">
<ul>
<li ng-click="fbLogin()"><span class="ifacebook"><img src="img/social-
icons/facebook.png"></span><a href="#" class="afacebook">sign in with
facebook</a></li>
<li ng-click="gplusLogin()"><span class="igoogleplus"><img src="img/social-
icons/googleplus.png"></span><a href="#" class="agoogleplus">sign in with
google+</a></li>
</ul>
</div>
<hr id="login-divider" />
<div id="login-reg">
<button id="btn-login" class="button button-clear button-positive
uppercase">Login</button>
<button id="btn-reg" class="button button-clear button-positive
uppercase">Register</button>
</div>
</div>
</ion-content>
<div id="footer" class="bar bar-footer">
<div class="title em-footer-title">© TechieDreams</div>
</div>
</ion-view>
答案 0 :(得分:1)
您的错误位于index.html文件中,
在正文中使用ng-app名称,如下所示,
<body ng-app="ionicApp">
该app名称应在app.js文件中使用,
var app = angular.module('ionicApp', ['ionic'])
因为,这是角度js的根元素,有助于执行我们的app.Reference:http://www.w3schools.com/angular/ng_ng-app.asp
答案 1 :(得分:0)
您的错误在主HTML中
将<div ng-app='login.html'>
更改为<div ng-app='ionicApp'>
,如第一个JS文件所述
答案 2 :(得分:0)
在您的正文标记中添加ng-app ="ionicApp"