1

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>

0

1 Answer 1

2

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'
})
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I tried that but with template vs templateURL. Works now :).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.