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

template parse error when using only responsive selectors. #59

Closed
ThomasBurleson opened this issue Dec 22, 2016 · 6 comments · Fixed by #121
Closed

template parse error when using only responsive selectors. #59

ThomasBurleson opened this issue Dec 22, 2016 · 6 comments · Fixed by #121
Assignees
Labels
bug has pr A PR has been created to address this issue
Milestone

Comments

@ThomasBurleson
Copy link
Contributor

ThomasBurleson commented Dec 22, 2016

Developers currently must use the default API when one or more responsive APIs are defined.

Consider the following scenario where the default is fxShow and the responsive API defined is fxShow.xs:

<div fxShow [fxShow.xs]="menuOpen" class="banner">
  I should hide and show
</div>  

The above ^ works fine. When I do not, however, specify the default non-responsive selector fxShow:

<div [fxShow.xs]="menuOpen" class="banner">
  I should hide and show
</div>  

then a Template Parse error occurs:

Uncaught (in promise): Error: Template parse errors:
Can't bind to 'fxShow.xs' since it isn't a known property of 'div'. ("
    </button>
    
    <div [ERROR ->][fxShow.xs]="menuOpen" class="banner">
      I should hide and show
    </div>  
"): TestApp@5:9
Error: Template parse errors:
Can't bind to 'fxShow.xs' since it isn't a known property of 'div'. ("
    </button>

Here is the Plunkr Demo that shows this.

NOTE: this has also been reported in /angular/issues/13645

@ThomasBurleson
Copy link
Contributor Author

Note that show.ts uses:

@Directive({selector: `
  [fxShow],
  [fxShow.xs]
  [fxShow.gt-xs],
  [fxShow.sm],
  [fxShow.gt-sm]
  [fxShow.md],
  [fxShow.gt-md]
  [fxShow.lg],
  [fxShow.gt-lg],
  [fxShow.xl]
`})
export class ShowDirective extends BaseFxDirective implements OnInit, OnChanges, OnDestroy {
  /**
   * Original dom Elements CSS display style
   */
  private _display = 'flex';

  /**
    * Subscription to the parent flex container's layout changes.
    * Stored so we can unsubscribe when this directive is destroyed.
    */
  private _layoutWatcher : Subscription;

  @Input('fxShow')       set show(val)     { this._cacheInput("show", val); }
  @Input('fxShow.xs')    set showXs(val)   { this._cacheInput('showXs', val); }
  @Input('fxShow.gt-xs') set showGtXs(val) { this._cacheInput('showGtXs', val); };
  @Input('fxShow.sm')    set showSm(val)   { this._cacheInput('showSm', val); };
  @Input('fxShow.gt-sm') set showGtSm(val) { this._cacheInput('showGtSm', val); };
  @Input('fxShow.md')    set showMd(val)   { this._cacheInput('showMd', val); };
  @Input('fxShow.gt-md') set showGtMd(val) { this._cacheInput('showGtMd', val); };
  @Input('fxShow.lg')    set showLg(val)   { this._cacheInput('showLg', val); };
  @Input('fxShow.gt-lg') set showGtLg(val) { this._cacheInput('showGtLg', val); };
  @Input('fxShow.xl')    set showXl(val)   { this._cacheInput('showXl', val); };

@ThomasBurleson
Copy link
Contributor Author

ThomasBurleson commented Dec 22, 2016

@vicb has submitted a Pull Request fix: angular/angular#13653

@ThomasBurleson ThomasBurleson changed the title Template Parse Error api: template parse error when using only responsive selectors. Dec 23, 2016
@ThomasBurleson ThomasBurleson changed the title api: template parse error when using only responsive selectors. template parse error when using only responsive selectors. Dec 23, 2016
@ThomasBurleson ThomasBurleson added bug has pr A PR has been created to address this issue labels Dec 23, 2016
@ThomasBurleson ThomasBurleson added this to the v2.0.0-beta.1 milestone Dec 23, 2016
@ThomasBurleson ThomasBurleson self-assigned this Dec 23, 2016
@ThomasBurleson
Copy link
Contributor Author

ThomasBurleson commented Jan 2, 2017

Fixed in Angular SHA 881eb894b: will be available in Angular v4.0.0-beta.2.

@thekalinga
Copy link

thekalinga commented Jan 3, 2017

@ThomasBurleson

A dumb question :)

Why is it angular 4 instead of angular 2?

@thekalinga
Copy link

Please ignore my previous comment

Found the reason for angular 4

https://angularjs.blogspot.com/2016/12/ok-let-me-explain-its-going-to-be.html

ThomasBurleson added a commit that referenced this issue Jan 21, 2017
* Many directive selectors were missing a `,` separator between then xs and gt-xs breakpoints
* fxShow, fxHide preserve and restore the element's original display CSS style
* added more tests standalone breakpoint selectors, disabled selectors, and deactivated mediaQueries

fixes #62, closes ##59.
andrewseguin pushed a commit that referenced this issue Jan 24, 2017
* fix(fxHide,fxShow): fix standalone breakpoint selectors

* Many directive selectors were missing a `,` separator between then xs and gt-xs breakpoints
* fxShow, fxHide preserve and restore the element's original display CSS style
* added more tests standalone breakpoint selectors, disabled selectors, and deactivated mediaQueries

fixes #62, closes ##59.

* fix(api): add missing comma-delimiter in breakpoint selectors

* add test to use md breakpoint via `fxHide.md`

* fix(fxShow, fxHide): restore proper display mode when not active

The fxHide and fxShow should not change the display mode to 'flex'. Instead
the display mode (when not 'none') should be the default (=== 'block')
or the explicitly assigned display mode for that element.

Fixes #105.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug has pr A PR has been created to address this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants