0

I'm new to angularjs and i'm doing a simple test script. According to the video tutorial i'm watching the code is correct. But does not run in my browser.

<!doctype html>
<html lang="en" ng-app>
    <head>
        <meta charset="UTF-8">
        <title>Angular Demo</title>
        <script src="lib/angular/angular.min.js"></script>
    </head>

<body>
<div ng-controller = "MyController">
    <h1>{{author.name}}</h1>
    <p>{{author.title + ',' + author.company}}</p>
</div>
<script>
function MyController($scope){
$scope.author = {
'name' : 'palitha ',
'title'  : 'test',
'company' : 'Home company'
}}
</script>
</body>
</html>

Can anybody show me where i got wrong.

6
  • you miss to include the code of the MyController class? in the page and the question both
    – Matteo
    May 4, 2015 at 4:58
  • is there any error in the console?
    – Divya MV
    May 4, 2015 at 4:59
  • are you running it using a local server ? also, where do you define your app object ?
    – svarog
    May 4, 2015 at 4:59
  • what version of angular?...as noted global functions are old convention
    – charlietfl
    May 4, 2015 at 5:02
  • Divya MV the console shows this error.Error: [ng:areq] errors.angularjs.org/1.3.15/ng/…
    – koli
    May 4, 2015 at 5:03

1 Answer 1

2

Man The videos you are seeing are old and the way they have shown to make a controller is also old this is not the way to make controller anymore in angular.

var app=angular.module('adb',[]);
app.controller('AppCtrl',function($scope){

});

or use the same angular version as the one in video you might be seeing lynda's angular tutorial see this one.

1
  • yes vengicx i think so. The video tutorial is somewhat old and i'm using the angularjs 1.3.15 which is the latest one.
    – koli
    May 4, 2015 at 5:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.