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

Questions about the AngularJS source code #1

Open
pomerantsev opened this issue Jun 8, 2014 · 3 comments
Open

Questions about the AngularJS source code #1

pomerantsev opened this issue Jun 8, 2014 · 3 comments

Comments

@pomerantsev
Copy link
Owner

  • In the src/ folder there are several files with .prefix and .suffix extensions. As far as I see they merely wrap the code inside the main .js file, and they get into the built angular.js file unaltered. Why is code divided into several chunks in such a way?
  • ng-view directive (src/ngRoute/directive) - why are two ng-view directives being registered?
  • minErr (src/minErr.js) - there is a paragraph in the opening comments to the file that minErr instances should have specific names. I totally don't understand why it is so.
  • What is transclusion essentially? Except that I can wrap some content into the directive's template. The comments in this issue are rather obscure to me: Isolated scope not isolated angular/angular.js#7716. It looks like much more is going on under the hood.
@al-the-x
Copy link
Collaborator

Just some notes regarding those topics. All great questions...

Re the .prefix and .suffix files:

I found someone else wondering the same which means this could be a little clearer. Probably worthy of a blog post or SO question. It has to do with the build process and wrapping up the built library in a self-calling closure for namespace protection. If that makes no sense, there's at least a half-hour of discussion around this topic.

Why are two ng-view Directives registered?

This gets complicated quickly, so probably worthy of another half-hour. The two (there are actually three in that file) are collaborating to produce the effect we see as ng-view. As API consumers, we only use the ng-view Directive; the others are by-products of our usage.

What is minErr and how is it used?

This is easier to demonstrate than to explain succinctly because it has to do with error states and displaying consistent error messages when an Error (JavaScript Exception) is thrown within the framework or userland code.

What is "transclusion" essentially?

This will take a full hour or more to cover, easily, and is one of the most confusing parts of Angular. Until you really understand how $scope works in Angular, the transclude voodoo does not make sense. I have to work it out on paper myself, sometimes.

@al-the-x
Copy link
Collaborator

Here is some sample code:

function doNothing () {
  console.log('nothing');
}

@al-the-x
Copy link
Collaborator

When to use link vs compile in Directives.

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