-
Notifications
You must be signed in to change notification settings - Fork 26.3k
feat: ngIf now supports else; saves condition to local var #13297
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
Changes from all commits
6b69e2e
b1d05dc
e2bcd0f
2ffe46c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -685,7 +685,7 @@ class TemplateParseVisitor implements html.Visitor { | |
} | ||
elementProps.forEach(prop => { | ||
this._reportError( | ||
`Property binding ${prop.name} not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "directives" section.`, | ||
`Property binding ${prop.name} not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations".`, | ||
sourceSpan); | ||
}); | ||
} | ||
|
@@ -704,7 +704,7 @@ class TemplateParseVisitor implements html.Visitor { | |
events.forEach(event => { | ||
if (isPresent(event.target) || !allDirectiveEvents.has(event.name)) { | ||
this._reportError( | ||
`Event binding ${event.fullName} not emitted by any directive on an embedded template. Make sure that the event name is spelled correctly and all directives are listed in the "directives" section.`, | ||
`Event binding ${event.fullName} not emitted by any directive on an embedded template. Make sure that the event name is spelled correctly and all directives are listed in the "@NgModule.declarations".`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
event.sourceSpan); | ||
} | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,32 @@ | |
This folder contains small example apps that get in-lined into our API docs. | ||
Each example contains tests for application behavior (as opposed to testing Angular's | ||
behavior) just like an Angular application developer would write. | ||
|
||
# Running the examples | ||
|
||
``` | ||
# # execute the following command only when framework code changes | ||
./build.sh | ||
|
||
# run when test change | ||
./modules/@angular/examples/build.sh | ||
|
||
# start server | ||
$(npm bin)/gulp serve-examples | ||
``` | ||
|
||
navigate to [http://localhost:8001](http://localhost:8001) | ||
|
||
# Running the tests | ||
|
||
``` | ||
# run only when framework code changes | ||
./build.sh | ||
|
||
# run to compile tests and run them | ||
./modules/@angular/examples/test.sh | ||
``` | ||
|
||
NOTE: sometimes the http server does not exits properly and it retans the `8001` port. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does not exits -> does not exit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @souldreamer I'll fix when merging the PR. thanks |
||
in such a case you can use `lsof -i:8001` to see which process it is and then use `kill` | ||
to remove it. (Or in single command: `lsof -i:8001 -t | xargs kill`) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* @license | ||
|
||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {$, ExpectedConditions, browser, by, element} from 'protractor'; | ||
import {verifyNoBrowserErrors} from '../../../../_common/e2e_util'; | ||
|
||
function waitForElement(selector: string) { | ||
const EC = ExpectedConditions; | ||
// Waits for the element with id 'abc' to be present on the dom. | ||
browser.wait(EC.presenceOf($(selector)), 20000); | ||
} | ||
|
||
describe('ngIf', () => { | ||
const URL = 'common/ngIf/ts/'; | ||
afterEach(verifyNoBrowserErrors); | ||
|
||
describe('ng-if-simple', () => { | ||
var comp = 'ng-if-simple' | ||
it('should hide/show content', () => { | ||
browser.get(URL); | ||
waitForElement(comp); | ||
expect(element.all(by.css(comp)).get(0).getText()).toEqual('hide show = true\nText to show'); | ||
element(by.css(comp + ' button')).click(); | ||
expect(element.all(by.css(comp)).get(0).getText()).toEqual('show show = false'); | ||
}); | ||
}); | ||
|
||
describe('ng-if-else', () => { | ||
var comp = 'ng-if-else' | ||
it('should hide/show content', () => { | ||
browser.get(URL); | ||
waitForElement(comp); | ||
expect(element.all(by.css(comp)).get(0).getText()).toEqual('hide show = true\nText to show'); | ||
element(by.css(comp + ' button')).click(); | ||
expect(element.all(by.css(comp)).get(0).getText()) | ||
.toEqual('show show = false\nAlternate text while primary text is hidden'); | ||
}); | ||
}); | ||
|
||
describe('ng-if-then-else', () => { | ||
var comp = 'ng-if-then-else' | ||
it('should hide/show content', () => { | ||
browser.get(URL); | ||
waitForElement(comp); | ||
expect(element.all(by.css(comp)).get(0).getText()) | ||
.toEqual('hide Switch Primary show = true\nPrimary text to show'); | ||
element.all(by.css(comp + ' button')).get(1).click(); | ||
expect(element.all(by.css(comp)).get(0).getText()) | ||
.toEqual('hide Switch Primary show = true\nSecondary text to show'); | ||
element.all(by.css(comp + ' button')).get(0).click(); | ||
expect(element.all(by.css(comp)).get(0).getText()) | ||
.toEqual('show Switch Primary show = false\nAlternate text while primary text is hidden'); | ||
}); | ||
}); | ||
|
||
describe('ng-if-let', () => { | ||
var comp = 'ng-if-let' | ||
it('should hide/show content', () => { | ||
browser.get(URL); | ||
waitForElement(comp); | ||
expect(element.all(by.css(comp)).get(0).getText()) | ||
.toEqual('Next User\nWaiting... (user is null)'); | ||
element(by.css(comp + ' button')).click(); | ||
expect(element.all(by.css(comp)).get(0).getText()).toEqual('Next User\nHello Smith, John!'); | ||
}); | ||
}); | ||
}); |
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.
or imported ?
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.
not sure I understand, what you mean by imported.
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 think he means: Property binding ${prop.name} not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations" or imported by the @NgModule