Skip to content

$transclude undefined on carousel initialization. #3

@cmusser

Description

@cmusser

I'm getting an error deep in the Angular library when trying to use the carousel in my project.

TypeError: undefined is not a function
    at new ngDirective.controller (http://localhost/lib/angular/angular.js:13962:5)
    at invoke (http://localhost/lib/angular/angular.js:2864:28)
    at Object.instantiate (http://localhost/lib/angular/angular.js:2874:23)
    at http://localhost/lib/angular/angular.js:4759:24
    at http://localhost/lib/angular/angular.js:4338:17
    at forEach (http://localhost/lib/angular/angular.js:138:20)
    at nodeLinkFn (http://localhost/lib/angular/angular.js:4323:11)
    at compositeLinkFn (http://localhost/lib/angular/angular.js:3969:15)
    at publicLinkFn (http://localhost/lib/angular/angular.js:3874:30)
    at http://localhost/lib/carousel.js:317:13 <div ng-mouseenter="pause()" ng-mouseleave="play()" class="carousel ng-isolate-scope ng-scope" data-carousel="" data-on-page-upcoming="loadPage(page, tmplCb)" data-give-carousel-to="onCarouselAvailable(carousel)"> 

Some background: our application is structured a bit differently than the sample. It uses routes, which specify controllers and the controllers are in a separate file. To start out, I borrowed the FlickrApi factory, CSS classes and controller functions, just to minimize the differences. So the overall effect should have been simply running the sample in the context of one of my partials, the underlying controller of which was modified to contain the same functions used by the example.

The problem seems related to initializing the carousel. Sometime after the function specified by the data-on-page-upcoming attribute runs, Angular is invoked and the exception shown above appears in the Javascript console.

What's failing is this Angular code. Specifically, $transclude is undefined.

var ngTranscludeDirective = ngDirective({
  controller: ['$transclude', '$element', function($transclude, $element) {
    $transclude(function(clone) {
      $element.append(clone);
    });
  }]
});

Does something need to be done to define $transclude? I've Googled around but haven't found a good answer. I did try setting "transclude" to true in the carousel directive. This didn't help and, truth be told, I don't know what it actually does.

Final note, I'm using a slightly newer Angular: 1.0.6. I tried to use the version used in the example (1.0.4)and it failed with the same error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions