2

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 File

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')
        };
    }
});

Getting Error: GET http://localhost:8600/angularsrc.js net::ERR_ABORTED and hence angular module not found. I tried including min.jquery earlier. I also tried changing angularsrc.js location, but nothing is working. Please help!!

2 Answers 2

2
<!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>

and your js is same

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')
        };
    }
});

This is what you exactly looking for

Sign up to request clarification or add additional context in comments.

4 Comments

If this is part of your previous answer, why not merge them?
The approach is good...but why can't I include external js file??
You can include. let me edit my post the way you were doing.
Still not working for external js file...works fine for js included in script tag(internal).
1

Your references should be inside head like

<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>

4 Comments

try to remove ng-app from html tag something like this <body ng-app="dropApp"> <div ng-controller="mainctrl"> {{your code or logic goes here}} </div> </body>
I don't think that ng-app in body tag or html tag would make any difference, still I tried and it did not work out.
sometime they make difference if we don't reference the way dom reads. it will be more clear if you put some extra code to understand the problem
See my comment. your reference error is gone away. please resolve other points where it break

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.