Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for annotating template and templateUrl properties on angular 1.5 component #231

Closed
martiansnoop opened this issue Feb 14, 2016 · 10 comments

Comments

@martiansnoop
Copy link

ng-annotate version: 1.2.1

It appears that with the new component, the template and templateUrl properties can also be a function called by the injector (forgive the toy example):

angular.module("myModule", [])
   .component("myComponent", {
        template: function($log) {
            $log.debug("doing a thing");
            return "<div>My Template</div>"
        },
       ...
 });

It doesn't look like ng-annotate is currently annotating these, though, so I had to fall back to the array syntax:

        template: ["$log", function($log) {
            $log.debug("doing a thing");
            return "<div>My Template</div>"
        }],
@gaelollivier
Copy link

+1

However you can avoid the array syntax using an explicit annotation:

.component('my-app', {
    // @ngInject
    templateUrl: ($locale) => `views/${$locale.id}/app/app.html`,
    controller: Controller
})

@michahell
Copy link

michahell commented Apr 6, 2016

Correct, the new angular 1.5 way of defining components breaks ngAnnotate / uglify.
Unknown provider: aProvider <- a is the error that is given in my case.

@brunomrpx
Copy link

👍

3 similar comments
@konclave
Copy link

+1

@rothlis
Copy link

rothlis commented Jun 3, 2016

+1

@jeremypele
Copy link

+1

@olov
Copy link
Owner

olov commented Jun 8, 2016

#245

@Splaktar
Copy link

Splaktar commented Aug 15, 2016

This is also an issue with controllers, i.e. this doesn't work (Unknown provider: aProvider <- a):

angular.module('myApp').component('sox', {
  controller: SoxController,
...
});

function SoxController($rootScope) {
...

While this does:

angular.module('myApp').component('sox', {
  controller: SoxController,
...
});
SoxController.$inject = ['$rootScope'];
function SoxController($rootScope) {
...

@olov olov closed this as completed Oct 1, 2016
@canac
Copy link

canac commented Feb 14, 2017

This feature would be useful in my application as well. Explicit annotation works fine, but it would be nice if this were automatic. @olov Does your closing this issue mean that this feature won't ever be added?

@omsmith
Copy link
Collaborator

omsmith commented Feb 14, 2017

@canac changes won't be made to ng-annotate going forward: #245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests