Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

WIP angular.component implementation [ci skip] #12166

Closed
wants to merge 1 commit into from

Conversation

caitp
Copy link
Contributor

@caitp caitp commented Jun 19, 2015

Needs tests and experimentation, it would be nice to make this work well
with TypeScript decorators for ease of use.

The whole "controller instantiated after templateUrl is loaded" thing seems
not-ideal, it would be cool if a templateUrl function could be a method of
the component controller.

Review on Reviewable

Needs tests and experimentation, it would be nice to make this work well
with TypeScript decorators for ease of use.

The whole "controller instantiated after templateUrl is loaded" thing seems
not-ideal, it would be cool if a templateUrl function could be a method of
the component controller.
this.component = registerComponent;
function registerComponent(name, bindings, controller) {
if (isString(name)) {
assertValidDirectiveName(name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this going to be called by registerDirective() anyway ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather see the error thrown in the registration method I call, rather than the underlying implementation.

@gkalpak
Copy link
Member

gkalpak commented Jun 19, 2015

By having the controller by some sort of configuration object, we are restricting the use of a string in certain cases (which might not be a good practice).

I would probably prefer an optional config object as a 4th parameter.

this.directive = function callRegisterDirective(name, directiveFactory) {
return registerDirective(name, directiveFactory, false);
};
function registerDirective(name, directiveFactory, isComponent) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not enough space for this.directive?

@petebacondarwin petebacondarwin added this to the 1.5.x - migration-facilitation milestone Jun 30, 2015
@ewinslow
Copy link
Contributor

Would it be possible to get docs on what usage of this API is going to look like? It's hard to visualize just looking at the code...

@caitp
Copy link
Contributor Author

caitp commented Jun 30, 2015

I envision it as using some kind of decorator library (we used to have a.js but that seems to have vanished somewhere), something like:

// TypeScript decorators:
@Component({
  templateUrl: 'meow.html',
  controllerAs: 'MEOWCTRL'
})
class MeowComponent {
  constructor() {
    // Do important controller-initialization-stuff!
  }
}

// ES5 JS with some kind of a.js-like library
Decorate(MeowComponent).With(Component, {
  templateUrl: 'meow.html',
  controllerAs: 'MEOWCTRL'
});
function MeowComponent() {
  // Do important controller-initialization stuff!
}

But you know, we are kind of just making it up as we go. No docs yet, I'll have to put more work into this before it gets that far

@shahata
Copy link
Contributor

shahata commented Sep 24, 2015

Closing in favor of #12933

@shahata shahata closed this Sep 24, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants