Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple angular app is not working

I'm trying to create basic angular app and it throws an error

<html>
<head>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
    <script type="text/javascript">
        var angularApp = angular.module('angularApp', []);
        angularApp.controller('Ctrl', function($scope) {});
    </script>
</head>
<body>
    <div ng-app ng-controller="Ctrl"></div>
</body>
</html>

Error:

Error: [ng:areq] http://errors.angularjs.org/1.4.3/ng/areq?p0=Ctrl&p1=not%20a%20function%2C%20got%20undefined
    at Error (native)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:6:416
    at Sb (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:22:18)
    at Qa (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:22:105)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:79:497
    at x (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:59:501)
    at S (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:60:341)
    at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:54:384)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:53:444
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:19:481'

What I did wrong?

like image 250
Poma Avatar asked Jul 23 '15 00:07

Poma


1 Answers

You must give ng-app the name of your app:

<div ng-app="angularApp" ng-controller="Ctrl"></div>
like image 128
agconti Avatar answered Sep 28 '22 16:09

agconti