0

the following is my app.html - template where i will be injecting my other partial views as to come,

<html ng-app="billApp">
<head>
  <!-- SCROLLS -->
  <!-- load bootstrap and fontawesome via CDN -->
  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.0/css/font-awesome.css" />

  <!-- SPELLS -->
  <!-- load angular via CDN -->
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js"></script>
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular-route.js"></script>
  <script src="script.js"></script>
</head>

<!-- define angular controller -->
<body ng-controller="mainController">

...

<!-- MAIN CONTENT AND INJECTED VIEWS -->
<div id="main">
    {{ message }}

    <!-- angular templating -->
    <!-- this is where content will be injected -->
</div>
</body>
</html>

And this is the script.js file which is the controller for the application,

// script.js

// create the module and name it scotchApp
var billApp = angular.module('billApp', []);

// create the controller and inject Angular's $scope
billApp.controller('mainController', function($scope) {

    // create a message to display in our view
    $scope.message = 'Everyone come and see!';
});

while i try to run the script.js file using my commandline

  1. change directory to nodejs directory

  2. type in 'node path-of-the-project-file\script.js'

which throws the following error, var billApp = angular.module('billApp', []); Reference error angular not defined.

I m somehow missing out on some basic detail. It would be great if someone could give me some directions here

3
  • 1
    Can't see anything wrong in your code. Please find the working plunker here: plnkr.co/edit/zQ7PIgaJlwkPVCHeNIR2?p=preview Commented Jul 14, 2016 at 8:56
  • include jquery before angular Commented Jul 14, 2016 at 9:00
  • Thanks @varit05 it works! Commented Jul 14, 2016 at 9:07

2 Answers 2

1

Replace

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular-resource.min.js"></script>

line with

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular-resource.min.js"></script>

Because its not getting library which is required by ngResource.

AND

Include this line in the beggining

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js"></script>

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

Comments

0

you need to incude jquery before the angular script

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

Comments

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.