Reputation: 14419
I've seen this issue asked however, I'm a little stumped with mine. Solutions state to remove one of the controllers. So when I remove the ng-controller=sigSearchResults from the body tag, my results do not get populated in the ng-grid="gridOptions" . How do rectify this?
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>
Upvotes: 1
Views: 234
Reputation: 164793
Yes, remove the ng-controller="sigSearchResults"
from your <body>
tag as you're using the $routeProvider
to configure routing and views and it doesn't look like your controller should be running at the top level.
Looks like all you're missing is the tempateUrl
in your route configuration, ie
when('/', {
templateUrl: 'sig-search-result-id',
controller: 'sigSearchResults'
})
Upvotes: 2