简体   繁体   中英

AngularJs Code does not work

Hello everybody and thanks to help me.

Here, the template

    <!DOCTYPE html>
<html ng-app="projectApp">
<head>
    <meta charset="UTF-8" />
    <title>Planning Poker !</title>
    <script src="resources/static/js/angular-1.2.21/angular.js"></script>
    <script src="resources/static/js/controllers.js"></script>
</head>
<body>
    <header>Planning Poker</header>
    <nav>
        <ul>
            <li>Add a Project</li>
            <li>The Project List</li>
            <li>About</li>
        </ul>
    </nav>
    <section>
        <div ng-controller="GreetingController">
        {{ greeting }}
        </div>
        <!--<form method="post" action="">
            <p><input type="text" placeholder="Name!"></p>
            <p><input type="text" placeholder="Mail!"></p>
            <p><input type="text" placeholder="Password!"></p>
        </form>-->
    </section>
    <footer></footer>
</body>
</html>

and the controller:

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

projectApp.controller('GreetingController', ['$scope', function($scope) {
    $scope.greeting = 'Hola!';
}]);

And, the directory structure.

http://i.stack.imgur.com/fWORv.png

The result is

http://i.stack.imgur.com/qfuHg.png

But I wish "Hola!" and not "{{greeting}}"

它没有看到angular.js,请尝试获取在线版本,将您的angular.js src替换为“ https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js

Ok the problem is fixed. It was a script problem.

<script src="js/angular-1.2.21/angular.js"></script>
    <script src="js/controllers.js"></script>

Indeed, it was directly mapped into "js" directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM