-
Notifications
You must be signed in to change notification settings - Fork 3.4k
docs(mdCompilerProvider): add respectPreAssignBindingsEnabled docs #11255
Conversation
@gkalpak can you please take a look at these docs changes to verify that they are still accurate with AngularJS 1.6 and the plans for AngularJS 1.7? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor comments/typos.
LGTM otherwise 👍
* @returns {*} current value if used as getter or itself (chaining) if used as setter | ||
* @param {boolean=} respected update the `respectPreAssignBindingsEnabled` state if provided, otherwise just return | ||
* the current Material `respectPreAssignBindingsEnabled` state. | ||
* @returns {boolean|function} current value if used as getter or itself (chaining) if used as setter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why function
? It returns the MdCompilerProvider
instance if used as setter.
* @module material.core.compiler | ||
* @description | ||
* The $mdCompiler service is an abstraction of AngularJS's compiler, that allows developers | ||
* to easily compile an element with options like in a Directive Definition Object. | ||
* The `$mdCompiler` is able to respect the AngularJS `$compiler.preAssignBindingsEnabled` state when using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$compiler.preAssignBindingsEnabled
--> $compileProvider.preAssignBindingsEnabled
(here and elsewhere).
* Only dynamic construction of elements such as Dialogs, Panels, Toasts, BottomSheets, etc. may be affected. | ||
* Invoking `$mdCompilerProvider.respectPreAssignBindingsEnabled(true)` will make **bindings** in | ||
* AngularJS Material custom components like `$mdDialog`, `$mdPanel`, `$mdToast`, or `$mdBottomSheet` | ||
* only available in the controller constructors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is wrong. (As mentioned below, invoking $mdCompilerProvider.respectPreAssignBindingsEnabled(true)
can result in different behaviors, depending on $compileProvider.preAssignBindingsEnabled()
and AngularJS version.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I've cleaned this up.
* compileData.element; // Compiled DOM element | ||
* compileData.link(myScope); // Instantiate controller and link element to scope. | ||
* app.config(function($mdCompilerProvider) { | ||
* $mdCompilerProvider.respectPreAssignBindingsEnabled(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insufficient indentation 😇
* compileData.element // Content Element (same as above) | ||
* compileData.link // This does nothing when using a contentElement. | ||
* app.config(function($mdCompilerProvider) { | ||
* $mdCompilerProvider.respectPreAssignBindingsEnabled(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insufficient indentation. Also, this does not guarrantee that bindings are pre-assigned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that when $mdCompilerProvider.respectPreAssignBindingsEnabled(false)
is called, it should guarantee that the bindings of AngularJS Material interim components are pre-assigned in AngularJS 1.5 and 1.6. Is this not correct? The description on line 119-120 seems pretty clear that the disabled (false
) option doesn't depend on AngularJS versions or settings.
* compileData.link // This does nothing when using a contentElement. | ||
* }); | ||
* function MyController() { | ||
* // Locals from Angular Material are set yet. e.g myVar is true. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are set yet --> are set already (?)
423a6db
to
cdd2918
Compare
* to easily compile an element with options like in a Directive Definition Object. | ||
* The `$mdCompiler` is able to respect the AngularJS `$compileProvider.preAssignBindingsEnabled` state when using | ||
* AngularJS versions between 1.5.10 and 1.7.0. | ||
* See the [AngularJS documentation for `$compile.preAssignBindingsEnabled` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$compile
--> $compileProvider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh! Not sure how I missed those, thanks.
* > The compiler powers a lot of components inside of AngularJS Material. | ||
* > Like the `$mdPanel` or `$mdDialog`. | ||
* To enable/disable whether the controllers of dynamic AngularJS Material components | ||
* (i.e. dialog, panel, toast, bottomsheet) respect the AngularJS `$compile.preAssignBindingsEnabled` flag, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$compile
--> $compileProvider
* ](https://code.angularjs.org/1.6.4/docs/api/ng/provider/$compileProvider#preAssignBindingsEnabled) | ||
* for more information. | ||
* Call this method to enable/disable whether Material-specific (dialog/panel/toast/bottomsheet) controllers respect the | ||
* AngularJS `$compile.preAssignBindingsEnabled` flag. Note that this doesn't affect directives/components created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$compile
--> $compileProvider
* The $mdCompiler service is an abstraction of AngularJS's compiler, that allows developers | ||
* to easily compile an element with options like in a Directive Definition Object. | ||
* The `$mdCompiler` is able to respect the AngularJS `$compileProvider.preAssignBindingsEnabled` state when using | ||
* AngularJS versions between 1.5.10 and 1.7.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like it respects it for 1.7.0 as well. How about:
* The `$mdCompiler` is able to respect the AngularJS `$compileProvider.preAssignBindingsEnabled` state when using
* AngularJS versions from 1.5.10 until (but not including) 1.7.0.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$compileProvider.preAssignBindingsEnabled
is removed from AngularJS in 1.7.0. Maybe that's your point? I'll try to refine it.
* These constitute the majority of AngularJS Material and user-created components. | ||
* Only dynamic construction of elements such as Dialogs, Panels, Toasts, BottomSheets, etc. may be affected. | ||
* Invoking `$mdCompilerProvider.respectPreAssignBindingsEnabled(true)` will effect **bindings** in | ||
* AngularJS Material custom components like `$mdDialog`, `$mdPanel`, `$mdToast`, or `$mdBottomSheet`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$mdDialog
etc. are services, not components. They don't even show components but usually templates with controllers (it'd be nice to add support for components but that's a separate story). Maybe:
...**bindings** in controllers created by AngularJS Material's services like
$mdDialog
,$mdPanel
,$mdToast
, or$mdBottomSheet
.
?
* }); | ||
* </hljs> | ||
* | ||
* Example with a content element | ||
* Assign Bindings Before the Constructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only true for AngularJS <1.6.0 or AngularJS <1.7.0 if $compileProvider.preAssignBindingsEnabled(true)
is called. Shouldn't it just say the reverse of the upper example's "Respect the AngularJS Compiler Setting"?
@andrewseguin @Splaktar It seems none of my comments were addressed in the merged commit; do you plan followups? |
PR Checklist
Please check that your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The docs site is missing the details about
$mdCompilerProvider.respectPreAssignBindingsEnabled
. The feature was added as part of #10016 and PR #10726. These docs can only be found in the code comments or CHANGELOG currently. It needs to be documented on the main docs site as well.Issue Number:
Fixes #11252.
What is the new behavior?
$mdCompilerProvider.respectPreAssignBindingsEnabled
is documented on the new$mdCompilerProvider
docs page under Services.Does this PR introduce a breaking change?
Other information
N/A