2017-08-30 55 views

回答

0

This Works。您還沒有指定了ng-appng-controller

Codepen Demo

代碼:

<html> 

<head> 
    <title>AngularJS Directives</title> 
</head> 

<body> 
    <h1>Sample Application</h1> 
    <div ng-app="myApp.controllers" ng-controller="Report as ctrl"> 

    <h4 ng-bind="ctrl.reports"></h4> 
    <h4 ng-bind="reportInfo"></h4> 
    </div> 
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> 
    <script src="a.js"></script> 
    <script src="abc.js"></script> 
</body> 

</html> 
+0

吉茲,更新了2秒,答案WOW –

1

你實際上是缺少這一點,

<div ng-app="myApp.controllers" ng-controller="Report as ctrl"> 

DEMO

angular.module("myApp.controllers", []); 
 

 
(function(angular) { 
 
    "use strict"; 
 
    function Report($scope) { 
 
    let ctrl = this; 
 
    ctrl.reports = "Rolys Royc H87H"; 
 
    $scope.reportInfo = "Aircraft"; 
 

 
    ctrl.$onInit = function() { 
 
     $scope.reportInfo = "Aircraft"; 
 
    }; 
 
    } 
 
    Report.$inject = ["$scope"]; 
 

 
    angular.module("myApp.controllers").controller("Report", Report); 
 
})(angular);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<html> 
 

 
<head> 
 
    <title>AngularJS Directives</title> 
 
</head> 
 
<body> 
 
    <h1>Sample Application</h1> 
 
    <div ng-app="myApp.controllers" ng-controller="Report as ctrl"> 
 
    <h4 ng-bind="ctrl.reports"></h4> 
 
    <h4 ng-bind="reportInfo"></h4> 
 
    </div> 
 
</body> 
 
</html>

相關問題