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

Template functions with annotations / ng-strict-di #11

Closed
karlhorky opened this issue Jan 15, 2016 · 5 comments
Closed

Template functions with annotations / ng-strict-di #11

karlhorky opened this issue Jan 15, 2016 · 5 comments

Comments

@karlhorky
Copy link

As per my GitHub comment in this angular.js issue, I'm running into issues with template functions with annotating or ng-strict-di.

I know this issue may belong in the main angular.js repo, but I just wanted to ask, in case someone here had an idea how to get around this.

@toddmotto
Copy link
Owner

Just pushed a fix for this, see 28ff08e

Demo for annotated code.

This allows for:

// Array annotations with minification
template: ['$element', '$attrs', function template(a, b) {
  console.log(a, b); // $element, $attrs
  return [
    '<div class="counter">',
      '<p>Counter component</p>',
      '<input type="text" ng-model="counter.count">',
      '<button type="button" ng-click="counter.decrement();">-</button>',
      '<button type="button" ng-click="counter.increment();">+</button>',
    '</div>'
  ].join('');
}]
// No annotations with automated minification (see source code `isArray` ternary + annotations)
template: function template(a, b) {
  console.log(a, b); // $element, $attrs
  return [
    '<div class="counter">',
      '<p>Counter component</p>',
      '<input type="text" ng-model="counter.count">',
      '<button type="button" ng-click="counter.decrement();">-</button>',
      '<button type="button" ng-click="counter.increment();">+</button>',
    '</div>'
  ].join('');
}
// Basic template String
template: [
  '<div class="counter">',
    '<p>Counter component</p>',
    '<input type="text" ng-model="counter.count">',
    '<button type="button" ng-click="counter.decrement();">-</button>',
    '<button type="button" ng-click="counter.increment();">+</button>',
  '</div>'
].join('')

@karlhorky
Copy link
Author

Thanks @toddmotto! Works great. 👍

@toddmotto
Copy link
Owner

@karlhorky Sweet! I've published 0.0.5 which includes the new automatic annotations, for NPM as well. Closing, over and out.

@toddmotto
Copy link
Owner

@karlhorky FYI, I've just published 0.0.6, which aligns with further component() changes, small Object merge rather than if statements: 1229b25

@karlhorky
Copy link
Author

💯 thanks, sounds good

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

2 participants