1
我看過這個問題,但是,我有點難倒我的。解決方案狀態移除其中一個控制器。所以當我從body標籤中刪除ng-controller = sigSearchResults時,我的結果不會被填充到ng-grid =「gridOptions」中。如何糾正這一點?角度控制器被叫兩次
var sig = angular.module('sig', ['ngRoute']);
sig.config([ '$routeProvider', function($routeProvider) {
$routeProvider.when('/search/:sig', {
template : ' ',
controller : 'sigSearchResults'
}).when('/', {
template : ' ',
controller : 'sigSearchResults'
}).otherwise({
redirectTo : '/'
});
} ]);
sig.controller('sigSearchResults', function($scope,$log,$http,$q,$routeParams, $window) {
console.log($routeParams);
//code that populates ng-grid to gridOptions element.
});
<html ng-app="sig">
<body ng-controller="sigSearchResults">
<div class="contentContainer">
<div ng-view></div>
<!-- This is the template for the result -->
<script type="text/ng-template" id="sig-search-result-id" >
<div ng-show="loading" style='clear:both; text-align: center;'>Loading report...<img src="../media/images/Wait3.gif"></div>
<div ng-show="!loading" class="gridStyle" ng-grid="gridOptions"></div>
</script>
</div>
感謝。我嘗試過,但模板與templateURL。現在工作:)。 – KingKongFrog 2014-08-28 05:00:20