无法在角度上正确加载消息

时间:2015-08-13 06:22:03

标签: javascript html angularjs

<!DOCTYPE html>
<html ng-app>
  <head>
    <script data-require="angular.js@*" data-semver="1.4.3"                src="https://code.angularjs.org/1.4.3/angular.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
  </head>

  <body ng-controller="MainController">
    <h1>This is the message {{message}}</h1>
  </body>
</html>

我的脚本文件有

var MainController = function($scope) {
  $scope.message = "Hi this is great ";
};

但结果仍显示{{message}}而非实际消息

2 个答案:

答案 0 :(得分:3)

这是一个有效的例子:

<body ng-app="myApp">
    <div ng-controller="MainController">
      Hello, {{message}}!
    </div>
</body>


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


var MainController = function($scope) {
    $scope.message = "Hi this is great ";
}

http://jsfiddle.net/sinaidoron/1c12r4hr/1/

答案 1 :(得分:0)

HTML代码:

retrofit interface methods(i.e callbacks, headers, body )

和script.js

retrofit package

工作示例Plunker Example