Prefix change : default mode and clear docs
See original GitHub issueChangelog of beta.11 says the md
prefix is being deprecated everywhere, in favor of mat
.
So I refactored all my project to move from md
to mat
for :
- modules (
MdInputModule
>MatInputModule
) - components (
<md-slider>
><mat-slider>
) - directives (
mdInput
>matInput
) - I already refactored the CSS classes before
But doing so, everything break with this error :
The "mat-" prefix cannot be used in ng-material v1 compatibility mode.
I saw in angular-prefix-adapter
that compatibility mode should be activated :
{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}
But it looks like a bug to me : why is this an error by default if this is supposed to be the new official prefix ?
And even without this change, why is this an error by default when it’s md-
prefix which causes compatibility issues and not the mat-
one ?
It should work out of the box.
And docs should be clear about all of this. Currently docs say to import MatXModule
but to then use <md-x>
element. I think I’m not the only confused by this.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:34
- Comments:10 (6 by maintainers)
Top GitHub Comments
Yeah I was stumped by this too, I thought from reading the changelog that the compatibility mode had been removed completely so I was surprised to see that the suggested refactor actually violates the “default” compatibility mode settings and that I had to enable compatibility mode (for the first time, and in all my unit tests etc) to get it working. I was also surprised that the handy tool didn’t add the provider itself.
I also think that the error message
The "mat-" prefix cannot be used in ng-material v1 compatibility mode.
is very unintuitive as it suggests that usingmat-
is invalid in compatibility mode, when in fact the opposite is true: onlymat-
can be used in compatibility mode. You can see the issue in the compatiblility source code - theX prefix cannot be used in compatibility mode
error message is thrown regardless of whether it is enabled.It is indeed very confusing. I would expect that after using the prefix updater tool, no errors should be reported without taking any further action.
However after using the tool I got
The "mat-" prefix cannot be used in ng-material v1 compatibility mode.
error mentioned above, which suggests that I had “v1 compatibility mode” on despite not opting it to use it.On the other hand in order to get rid of the error, I had to add
NoConflictStyleCompatibilityMode
module dependency to my app module and all unit tests which suggest that “v1 compatibility mode” was actually off, unless the intended role ofNoConflictStyleCompatibilityMode
module it to opt out of “v1 compatibility mode”.This definitely needs a clarification.