Angular 1.2有效但不是1.4

时间:2016-02-02 15:41:33

标签: javascript angularjs

<!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"
};
}

大家好,我只是好奇为什么这个代码在angular 1.4中不起作用,这是最新版本。我检查了其他线程,但似乎有错误与我的有点不同。我的1.2工作正常,而不是1.4。

1 个答案:

答案 0 :(得分:1)

希望这会对你有所帮助。

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">