Error: angular is undefined in app.js - angularjs

I have the following simple html file
<!DOCTYPE html>
<html ng-app="store">
<head>
<title></title>
<link href="bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<script src="angular.min.js" type="text/javascript" ></script>
<script src="app.js"></script>
<p>{{Hello Angular!!}}</p>
</body>
</html>
and app.js file
'use strict';
var app = angular.module('store', []);
I'm getting error "angular is undefined" while running HTML file under webserver. Can anyone please suggest what I'm doing wrong!

Please check your reference file.
like.
<!DOCTYPE html>
<html ng-app="store">
<head>
<title></title>
<link href="bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<script src="https://code.angularjs.org/1.4.0-beta.5/angular.js"></script>
<script src="app.js"></script>
<p>{{Hello Angular!!}}</p>
</body>
</html>

Related

Uncaught referenceError : Angular is not defined

I am seeing the error as shown in the image.
Error displayed in the console.
This is my App.js code:
var app = angular.module('PopupDemo',[]);
app.controller('PopupDemoCont',function($scope) {
});
This is my HTML code:
<html>
<head>
<title>SignUp</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="signup.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="js/App.js"></script>
<script src="js/angular.min.js"></script>
<script src="js/ui-bootstrap-tpls-0.14.3.min.js"></script>
</head>
<body ng-app="PopupDemo">
<div data-toggle="validator" class="container-fluid" ng-controller="PopupDemoCont">
<h1><b>Sign Up</b></h1>
</br>
<form id="form" name="userForm" action="Registration.html">
</body>
</html>
Can anyone fix this?
Your app.js shoud be below angular reference
<script src="js/angular.min.js"></script>
<script src="js/App.js"></script>
Your references Order should be
<script src="js/angular.min.js"></script>
<script src="js/App.js"></script>

getting started with reactjs component is not working

i am new to reactjs and facing problem at my first step.
please help me.
below is my code..
i have written same code in "custom.jsx" file but problem is the same(no output)
<!DOCTYPE html>
<html lang="en">
<head>
<title>react demo</title>
<link rel="stylesheet" type="text/css" href="common/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="common/css/style.css" />
</head>
<body>
<div id="root"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom-server.js"></script>
<script type="text/javascript" src="common/js/bootstrap.min.js"></script>
<script src="common/js/custom.jsx"></script>
<script type="text/jsx">
var button = React.createClass({
render: function(){
return (
<button>go</button>
)
}
});
React.render(<button />,document.getElementById("root"));
</script>
</body>
</html>
Change the name of variable it will work.
Reason is: name starts with small letters are treated as HTML elements, that's why all React components must start with a upper case letter, Check this:
<!DOCTYPE html>
<html lang="en">
<head>
<title>react demo</title>
<link rel="stylesheet" type="text/css" href="common/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="common/css/style.css" />
</head>
<body>
<div id="root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.23.1/babel.min.js"></script>
<script type="text/jsx">
var Button = React.createClass({
render: function(){
return (
<button>go</button>
)
}
});
ReactDOM.render(<Button/> ,document.getElementById("root"));
</script>
</body>
</html>

SCRIPT5009: 'Backbone' is undefined in IE11

I have following code, and try to run in IE11.Can not figure out what is wrong.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
<script>
var Todo = Backbone.Model.extend({});
</script>
</body>
</html>
Did you checked if the files exists? Neither underscore and backbone are accessible via the provided links.
Replace the source files with:
<script src="http://underscorejs.org/underscore-min.js"></script>
<script src="http://backbonejs.org/backbone-min.js"></script>

Display Hello, Angular! in Angular JS

I have written the following program to print Hello, Angular! but it does not work. Please guide.
<!DOCTYPE html>
<html ng-app="gemStore" ng-init="person={text:'Hello, Angular!'>
<head>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css" />
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body>
<h1><div>
{{person.text}}
</div></h1>
</body>
</html>
You need a closing brace and quote for the ng-init
ng-init="person={text:'Hello, Angular!'}"
Replace :
ng-init="person={text:'Hello, Angular!'>
with:
ng-init="person={text:'Hello, Angular!'}">
You have typo mistake, replace your code with below.
<!DOCTYPE html>
<html ng-app="gemStore" ng-init="person={text:'Hello, Angular!'}>
<head>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css" />
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body>
<h1><div>
{{person.text}}
</div></h1>
</body>
</html>
You forgot the right bracet and the quote. See the example below.

Error when injecting angular-animate.js

I am receiving the following error when injecting angular-animate.js:
Unknown provider: $animateProvider from ngAnimate
Here is my app.js:
var MyApp = angular.module("MyApp", ["ui.bootstrap", "ngAnimate"])
Here is head of index.html:
<html lang="en" ng-app="MyApp">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript" src="app.js"></script>
<script type="text/javascript" src="angular-animate.js"></script>
<script type="text/javascript" src="ui-bootstrap-tpls-0.6.0.min.js"></script>
<script type="text/javascript" src="controllers.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css" />
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<title>My App</title>
</head>
<body ng-controller="AppCtrl" style="padding-bottom: 70px">
Bootstrap alone is loaded fine.
What am I doing wrong?
Here is the plnkr
I got a different error with your code. I got a missing $routeProvider error.
As the first line of your app.js try this:
var MyApp = angular.module("MyApp", ["ngRoute", "ngAnimate", "ui.bootstrap"])
instead of
var MyApp = angular.module("MyApp", ["ngAnimate", "ui.bootstrap"])
And add it your header:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-route.js"></script>
By the way, using the non-minified version of Angular in plnkr.co gives a more human readable error message in these cases.
You are declaring app.js before the angular-animate library. Try this:
<html lang="en" ng-app="MyApp">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript" src="angular-animate.js"></script>
<script type="text/javascript" src="ui-bootstrap-tpls-0.6.0.min.js"></script>
<script type="text/javascript" src="app.js"></script>
<script type="text/javascript" src="controllers.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css" />
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<title>My App</title>
</head>
<body ng-controller="AppCtrl" style="padding-bottom: 70px">

Resources