脚本src没有加载javascript for angular

时间:2017-11-18 07:19:10

标签: javascript angularjs html5

HTML

    <!DOCTYPE html>
<html ng-app="dropApp">
<head>
    <meta charset="utf-8" />
    <title>DropBox</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
</head>
<body ng-controller="mainctrl">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.js"></script>


    <div class="jumbotron">
        <div class="container">
            <div class="col-sm-8 col-sm-offset-2">
                <a id="btn-login" ng-click="login()" ng-model="logbut" ng-show="logbut" class="btn btn-success">Login  </a>
                <div ng-include="template"></div>
            </div>
        </div>
    </div>
    <div class="credits text-center">
        <p>
            Amey Totawar
        </p>
    </div>
    <script src="angularsrc.js"></script>

</body>
</html>

Javascript文件

var dropApp = angular.module("dropApp",[]);
var path = require('path');

dropApp.controller("mainctrl", function($scope) {
    $scope.logbut = true;
    $scope.login = function() {
        $scope.logbut = false;
        $scope.template = {
            name: 'login.html',
            url: path.join(__dirname,'views','login.html')
        };
    }
});

获取错误: GET http://localhost:8600/angularsrc.js net :: ERR_ABORTED,因此找不到角度模块。 我之前尝试过包含min.jquery。 我也试过改变angularsrc.js的位置,但没有什么工作。 请帮忙!!

2 个答案:

答案 0 :(得分:2)

// read from dongle
var connectionString = ...;
var ctx = new StackContext(connectionString);

和你的js相同

<!DOCTYPE html>
<html ng-app="dropApp">
<head>
    <meta charset="utf-8" />
    <title>DropBox</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.js"></script>
    <script src="angularsrc.js"></script>
</head>
<body ng-controller="mainctrl">
    <div class="jumbotron">
        <div class="container">
            <div class="col-sm-8 col-sm-offset-2">
                <a id="btn-login" ng-click="login()" ng-model="logbut" ng-show="logbut" class="btn btn-success">Login  </a>
                <div ng-include="template"></div>
            </div>
        </div>
    </div>
    <div class="credits text-center">
        <p>
            Amey Totawar
        </p>
    </div>

</body>
</html>

这就是你正在寻找的东西

答案 1 :(得分:1)

你的引用应该像

一样
<html ng-app="dropApp">
<head>
    <meta charset="utf-8" />
    <title>DropBox</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.js"></script>
    <script src="angularsrc.js"></script>
</head>
<body ng-controller="mainctrl">
    {{your code or logic goes here}}
</body>
</html>