Angularjs 蛋头角度控制器不工作

Angularjs 蛋头角度控制器不工作,angularjs,binding,controller,Angularjs,Binding,Controller,我试着跟随eggheads angularJS教程。我有相同的代码,但我的不工作 以下是我正在使用的代码: index.html: <!DOCTYPE html> <html> <head> <title>AngularJS Tutorials</title> <link rel="stylesheet" href="../foundation/css/foundation.min.css"> &

我试着跟随eggheads angularJS教程。我有相同的代码,但我的不工作

以下是我正在使用的代码:

index.html:

<!DOCTYPE html>

<html>

<head>
    <title>AngularJS Tutorials</title>
    <link rel="stylesheet" href="../foundation/css/foundation.min.css">
    <script type="text/javascript" src="main.js"></script>
</head>

<body>
    <div ng-app="">
        <div ng-controller="FirstCtrl">
            <h1>{{data.message + " world"}}</h1>
            <div class="{{data.message}}">
                Wrap me with a foundation component.
            </div>
        </div>
    </div>

    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js"></script>
</body>

</html>

嗨,你错过了几件事

  • 您的应用程序声明:

    var-app=angular.module('app',[])

  • 控制器的声明

    app.controller('FirstCtrl',FirstCtrl)

  • 在html中

    ng app=“app”

  • var-app=angular.module('app',[]);
    应用控制器('FirstCtrl',FirstCtrl);
    函数FirstCtrl($scope){
    $scope.data={
    信息:“小组”
    };
    }
    
    {{data.message+“world”}
    用基础组件包装我。
    
    问题在于角度版本

    您的版本是
    1.3.4
    ,而不是
    1.2.3

    • 带有角度1.2.3(蛋头)的应用程序:
    • 具有角度1.3.4的应用程序:
    function FirstCtrl($scope) {
        $scope.data = {message: "panel"};
    }