ng-include Javascript未被执行

时间:2015-05-18 10:16:31

标签: javascript jquery html angularjs

我处于重构的状态,所以我将所有登录控制器内容从Autenticate.html移到了HTML模板中。这一切都在移动之前工作,但现在我正在使用的Javascript没有被调用。我有这样的Javascript:

login.js

$(function () {
    $("#userNameInput").keypress(function (e) {
        if (e.keyCode === 13) $("#passwordInput").focus();
    });

    $("#passwordInput").keypress(function (e) {
        if (e.keyCode === 13) $("#loginButton").click();
    });
});

Authenticate.html

<!DOCTYPE html>
<html ng-app="iBOSModule">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" /><base href="/">
    <title>Welcome to iBOS</title>
    <script src="/Scripts/angular.min.js"></script>
    <script src="/Scripts/angular-route.min.js"></script>
    <script src="/Scripts/promise-tracker.js"></script>
    <script src="/Scripts/angular-busy.min.js"></script>
    <script src="/Scripts/http-interceptor.js"></script>
    <script src="/Scripts/ui-bootstrap-tpls-0.12.1.min.js"></script>
    <script src="/Scripts/angular-animate.min.js"></script>
    <script src="/Scripts/dirPagination.js"></script>
    <script src="/Scripts/linq.js"></script>
    <script src="/Scripts/jquery-1.10.2.js"></script>
    <script src="/Scripts/bootstrap.js"></script>
    <script src="/angular/components/login/scripts/login.js"></script>
    <script src="/angular/components/shared/scripts/app.js"></script>
    <script src="/angular/components/login/controllers/login.js"></script>
    <link href="/Content/bootstrap.min.css" rel="stylesheet" />
    <link href="/Content/acs.css" rel="stylesheet"/>
</head>
<body style="background-image: url(/Content/Images/Jet-Above-The-Clouds.jpg);" ng-cloak>
<div class="container body-content top-buffer">
    <ng-include src="'/angular/components/login/templates/login-template.html'"></ng-include>
</div>
</body>
</html>

登录-template.html

<div class="well center-block" style="max-width: 489px;" ng-controller="LoginCtrl">
    <div class="container">
        <div class="row">
            <img src="/Content/Images/ibos_logo.png" class="img-responsive" />
        </div>
        <div class="row col-sm-10 col-sm-offset-1 top-buffer remove-bottom-buffer" ng-show="hasFailed()">
            <div class="alert alert-danger" role="alert">
                <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
                <span class="sr-only">Error:</span>
                Invalid credentials. Please try again.
            </div>
        </div>
        <div class="row col-sm-10 col-sm-offset-1 top-buffer remove-bottom-buffer" ng-show="hasFault()">
            <div class="alert alert-danger" role="alert">
                <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
                <span class="sr-only">Error:</span>
                An error occurred.
            </div>
        </div>
        <div class="row col-sm-10 col-sm-offset-1 top-buffer">
            <input ng-model="userName" type="text" class="form-control" placeholder="User Name" ng-disabled="isAuthenticating()" id="userNameInput" tabindex="0">
        </div>
        <div class="row col-sm-10 col-sm-offset-1 top-buffer">
            <input ng-model="password" type="password" class="form-control" placeholder="Password" ng-disabled="isAuthenticating()" id="passwordInput" tabindex="1">
        </div>
        <div class="row col-sm-10 col-sm-offset-1 top-buffer">
            <button id="loginButton" class="btn btn-default pull-right" ng-hide="isAuthenticating()" ng-click="authenticate()" tabindex="2">Login</button>
            <button id="loadingButton" class="btn btn-default pull-right disabled" ng-show="isAuthenticating()"><img src="/Content/Images/ajax-loader.gif" /></button>
        </div>
    </div>
</div>

问题是在触发按键事件时没有调用Javascript。实际绑定正在发生 - 我在F12中检查并且正在调用绑定函数。

没有其他任何改变。为什么函数没有被调用?

0 个答案:

没有答案