0
<!doctype html>
<html lang="en" ng-app>
<head>
    <meta charset="utf-8">
    <title>Caketime</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/app.css">
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
    <script src="app.js"></script>
</head>
<body>

    <div id="header-wrapper" ng-controller="HeaderCtrl">
        <span class="logo pull-left">{{appLogo.title}}</span>
        <span class="tagline pull-left">{{appLogo.tagline}}</span>
        <div class="nav-wrapper pull-left">
            <ul class="nav nav-pills">
                <li class="active"><a href="#">Books</a></li>
                <li><a href="#">Kart</a></li>
            </ul>
        </div>
    </div>

</body>

var HeaderCtrl = function($scope) {
$scope.appLogo = {
    title: "Cakes",
    tagline: "CakesRUs"
};
}

Hello all, I was just curious why this code does not work in angular 1.4, which is the most current version. I have checked the other threads but it seems there errors were a little different than mine. Mine works fine on 1.2 just not on 1.4.

Onion
  • 127
  • 1
  • 1
  • 8
  • whats the error in console? – varun aaruru Feb 02 '16 at 15:42
  • Error: [ng:areq] http://errors.angularjs.org/1.4.9/areq?p0=HeaderCtrl&p1=not%20a%20function%2C%20got%20undefined at Error (native) failed to load resource : net :: ERR_File_NOT_FOUND – Onion Feb 02 '16 at 15:46
  • Sounds like it's having problems trying to download angular, what does your script tag for angular 1.4 look like? – George Feb 02 '16 at 15:50
  • And you have not loaded angular file correctly(check network tab please)..The problem is the way you are defining controller is problematic, you are following global function for controller, [this answer](http://stackoverflow.com/a/28728380/2435473) would help you.. – Pankaj Parkar Feb 02 '16 at 15:50
  • try another cdn and check @Onion – varun aaruru Feb 02 '16 at 15:56
  • this is it George. – Onion Feb 02 '16 at 15:59

1 Answers1

1

hope this will help you.

var App = angular.module('App',[]);

App.controller('HeaderCtrl', ['$scope', function($scope) {
    $scope.appLogo = {
    title: "Cakes",
    tagline: "CakesRUs"
    };
}]);

// html header to change
// <html lang="en" ng-app="App">
peterfurax
  • 51
  • 3
  • this works. Thank you! Can you please explain , if possible, of what i was doing wrong? – Onion Feb 02 '16 at 16:03
  • i think you have a timeout with the CDN, when you load html. i just wrote this controller, in the better way to avoid any future problems. – peterfurax Feb 02 '16 at 16:29