0

I am making a simple program in Angular.js to print a name. Alas, still it shows an error.

HTML:

<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.0/angular2.min.js"></script>
<script src="angularScript.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
{{name}}
</body>
</html>

AngularScript.js

// Defining Module
var app = angular.module('myApp',[]);

// Defining Controller
app.controller('myCtrl', function ($scope) {
$scope.name = "Peter";
});

Error:

->  Uncaught ReferenceError: System is not defined
->  Uncaught ReferenceError: angular is not defined

Can someone help me out, with where is the problem?

2
  • 4
    you're writing angular 1.x but have angular 2 reference, either reference angular 1 or write angular 2 code. Easiest to fix your problem is the first alternative. But it could be a good idea to learn angular 2 as well Commented Jan 8, 2016 at 7:50
  • 1
    you mean angular2 is not backward compatible with angular1? Commented Jan 8, 2016 at 7:56

1 Answer 1

3

Use the correct version of AngularJS script file. You are writing AngularJS script of 1.4 but including 2.0.

Just replace your script tag with:

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

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

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.