0
继网上的例子,我有login.html
是这样的:更改点击按钮(AngularJS)上的页面?
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.js"></script>
<script type="text/javascript" src="app/app.login.js"></script>
<div id="loginButton" ng-app="loginButton" ng-controller="loginControl">
<button ng-click="enterSite()">
Enter
</button>
</div>
然后在app.login.js
:
var appButton = angular.module("loginButton", []);
appButton.controller("loginControl", ["$scope", "$window", function($scope, $window){
$scope.enterSite = function(){
$window.location.href = "../index.html";
}
}]);
然而,当我按下按钮它不重定向到index.html
。浏览器日志中没有错误。我从工作示例中复制了大部分格式,所以我找不到为什么它不适用于我。
任何提示将不胜感激。
你说得对,我提供了工作的摘录。然而,我很尴尬地在login.html中使用了2 ng-app(经过大量研究后,我才发现你只能使用一个),所以我想它只是忽略了两者。感谢您通知我错误不在我提供的内容中。 – Yifan
@Yifan发生了:)。要加载第二个应用程序,您必须通过代码手动引导它。 –