Proposal: Replace ui-router-specific implementation w/ generic implementation #11233
Description
Proposal:
Currently Angularjs Material has code that is tightly coupled to UI-Router, while the code in it self isn't really harmful, it provides the question, what about the next router, what about the next custom link directive etc...
This simply isn't generic...
Instead, provide a way to override the behavior, e.g. by a service service/provider where users of Angularjs Material can change how Angularjs material figures out when a button should be a link etc...
What is the use-case or motivation for changing an existing behavior?
Making the framework more generic and loosen up the tight coupling to e.g. UI-Router. Allowing for integration to other custom made directives etc. which are suppose to indicate links and so on.
Which versions of AngularJS, Material, OS, and browsers are affected?
v1.1.8
Is there anything else we should know? Stack Traces, Screenshots, etc.
I wanted to submit this as a proposal PR instead of just an issue, but I ran into some ambiguities which requires me to understand the meaning behind before I proceed.
Button definition of isAnchor:
Button use of isAnchor:
- https://github.com/angular/material/blob/master/src/components/button/button.js#L133
- https://github.com/angular/material/blob/master/src/components/button/button.js#L151
List Item use of detection:
List Item attr copy:
Menu Service Provider:
NavBar insertion if attributes:
- https://github.com/angular/material/blob/master/src/components/navBar/navBar.js#L410
- https://github.com/angular/material/blob/master/src/components/navBar/navBar.js#L428
- https://github.com/angular/material/blob/master/src/components/navBar/navBar.js#L432
- https://github.com/angular/material/blob/master/src/components/navBar/navBar.js#L458
The last one is probably the most challenging one as it adds bindings etc... But it shouldn't be impossible to make a more flexible design.
But what i don't get is the different ways that "links" are detected:
//button:
angular.isDefined(attr.href) || angular.isDefined(attr.ngHref) || angular.isDefined(attr.ngLink) || angular.isDefined(attr.uiSref);
//list item:
tAttrs.ngClick || tAttrs.ngDblclick || tAttrs.ngHref || tAttrs.href || tAttrs.uiSref || tAttrs.ngAttrUiSref
//menu service provider
(hasAnyAttribute(target, ['ng-click', 'ng-href', 'ui-sref'])
etc...
It would be much appreciated if anyone was able to explain that... Then perhasp I could start on a PR