aboutsummaryrefslogtreecommitdiffstats
path: root/src/Compiler.js
diff options
context:
space:
mode:
authorMisko Hevery2011-02-12 10:13:28 -0800
committerMisko Hevery2011-02-16 01:03:12 -0500
commitef4bb28be13e99f96c9ace5936cf26a174a0e5f0 (patch)
tree833057505e430cac064214ac3d55c687338da2a9 /src/Compiler.js
parent496e6bf9016d33a7cf2f4730d06a8655f01ca5cb (diff)
downloadangular.js-ef4bb28be13e99f96c9ace5936cf26a174a0e5f0.tar.bz2
Change API angular.compile(element)([scope], [element/true])
Diffstat (limited to 'src/Compiler.js')
-rw-r--r--src/Compiler.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/Compiler.js b/src/Compiler.js
index 6aee40b8..890f2510 100644
--- a/src/Compiler.js
+++ b/src/Compiler.js
@@ -80,30 +80,30 @@ function Compiler(markup, attrMarkup, directives, widgets){
}
Compiler.prototype = {
- compile: function(element) {
- element = jqLite(element);
+ compile: function(templateElement) {
+ templateElement = jqLite(templateElement);
var index = 0,
template,
- parent = element.parent();
+ parent = templateElement.parent();
if (parent && parent[0]) {
parent = parent[0];
for(var i = 0; i < parent.childNodes.length; i++) {
- if (parent.childNodes[i] == element[0]) {
+ if (parent.childNodes[i] == templateElement[0]) {
index = i;
}
}
}
- template = this.templatize(element, index, 0) || new Template();
- return function(element, parentScope){
- element = jqLite(element);
- var scope = parentScope && parentScope.$eval
- ? parentScope
- : createScope(parentScope);
+ template = this.templatize(templateElement, index, 0) || new Template();
+ return function(scope, element){
+ scope = scope || createScope();
+ element = element === true
+ ? templateElement.cloneNode()
+ : (jqLite(element) || templateElement);
element.data($$scope, scope);
template.attach(element, scope);
scope.$element = element;
scope.$eval();
- return scope;
+ return {scope:scope, view:element};
};
},