angularjs-directiveangular-ui-gridcelltemplate

html file as cellTemplate not working in directive compile: or pre: function


Before i came here, i did read through this thread: https://github.com/angular-ui/ui-grid/issues/2078, but still didn't find the solution.

Pretty similar issue:

angular.module('XXX')
directive(
'myDirective', [function() {
    return {
        restrict: 'E',
        scope: {data: '='},
        templateUrl: 'myTemplate.html',
        compile: function() {
            return {
                pre: function(scope, elem) {
                    var cT = '<div>Details</div>';
                    scope.gridOptions = {
                        columnDefs: [{ field: 'myField', displayName: 
                         'myFieldName', cellTemplate: 'myCellTemplate.html'}]
                    };
                }
            }
        }
}]);

I copied exactly in cT to 'myCellTemplate.html' and tried to load it, not working, but if i use the inline cT it's working fine. I tired to change 'myTemplate.html' to 'myCellTemplate.html' in templateUrl: to see if directive can successfully load the html, and it was actually also working. So i'm wondering does compile: -> pre: function have a different path so it couldn't find 'myCellTemplate.html' in its current path?

Any thoughts?

Update

Worked after i changed the path to '/partial/.../myCellTemplate.html'


Solution

  • Worked after i changed the path to '/partial/.../myCellTemplate.html'