This repository has been archived by the owner on Feb 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
Web Component support: binding to properties #1277
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "paper-example", | ||
"version": "0.0.1", | ||
"homepage": "https://github.com/angular/angular.dart", | ||
"authors": [ | ||
"James deBoer <[email protected]>" | ||
], | ||
"description": "Paper with AngularDart", | ||
"main": "web/index.html", | ||
"license": "MIT", | ||
"private": true, | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
], | ||
"dependencies": { | ||
"polymer": "Polymer/polymer#~0.3.4", | ||
"paper-elements": "Polymer/paper-elements#~0.3.4", | ||
"core-elements": "Polymer/core-elements#~0.3.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../bower_components/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:angular/angular.dart'; | ||
import 'package:angular/application_factory.dart'; | ||
|
||
|
||
main() { | ||
var injector = applicationFactory() | ||
.run(); | ||
var scope = injector.get(Scope); | ||
scope.context['text'] = "Hello future"; | ||
scope.context['max'] = 20; | ||
scope.context['curValue'] = 12; | ||
scope.apply(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="viewport" | ||
content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> | ||
|
||
<!-- 1. Load platform.js for polyfill support. --> | ||
<script src="bower_components/platform/platform.js"></script> | ||
|
||
<!-- 2. Use an HTML Import to bring in the element. --> | ||
<link rel="import" | ||
href="bower_components/paper-progress/paper-progress.html"> | ||
<script type="application/dart" src="paper_progress.dart"></script> | ||
<script src="packages/browser/dart.js"></script> | ||
<style> | ||
div { padding: 0.25em; } | ||
</style> | ||
</head> | ||
<body> | ||
<h2>A quick demo of the Polymer paper-progress widget in an AngularDart app.</h2> | ||
<p>The max ({{max}}) and value ({{curValue}}) properties are bound through bind-* semantics</p> | ||
|
||
<p>Text from Angular: <b>{{text}}</b></p> | ||
|
||
<div> | ||
<paper-progress bind-max=max bind-value=curValue></paper-progress> | ||
</div> | ||
|
||
<p> | ||
Change the value through an ng-model bound input box: | ||
<input type="text" ng-model="curValue"> | ||
</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
library angular.dom.web_components_spec; | ||
|
||
import '../_specs.dart'; | ||
import 'dart:js' as js; | ||
|
||
registerElement(String name, prototype) { | ||
return (new js.JsObject.fromBrowserObject(document)).callMethod('registerElement', | ||
[name, new js.JsObject.jsify({"prototype": prototype })]); | ||
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.
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. This is untyped because prototype could be a JsObject as well, although I don't use one below. The {"prototype": prototype} comes from the registerElement spec. 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.
Thanks, didn't know about that |
||
} | ||
|
||
|
||
|
||
main() { | ||
describe('WebComponent support', () { | ||
TestBed _; | ||
|
||
customProp(String prop, [elt]) { | ||
if (elt == null) elt = _.rootElement; | ||
return (new js.JsObject.fromBrowserObject(elt))[prop]; | ||
} | ||
|
||
beforeEach((TestBed tb) { | ||
_ = tb; | ||
}); | ||
|
||
it('should create custom elements', () { | ||
registerElement('tests-basic', {'prop-x': 6}); | ||
|
||
// Create a web component | ||
_.compile('<tests-basic></tests-basic>'); | ||
expect(customProp('prop-x')).toEqual(6); | ||
}); | ||
|
||
|
||
it('should bind to Custom Element properties', () { | ||
registerElement('tests-bound', {'prop-y': 10}); | ||
_.compile('<tests-bound bind-prop-y=27></tests-bound>'); | ||
|
||
// Scope has not been digested yet | ||
expect(customProp('prop-y')).toEqual(10); | ||
|
||
_.rootScope.apply(); | ||
expect(customProp('prop-y')).toEqual(27); | ||
}); | ||
|
||
|
||
it('should bind to a non-existent property', () { | ||
registerElement('tests-empty', {}); | ||
_.compile('<tests-empty bind-new-prop=27></tests-empty>'); | ||
_.rootScope.apply(); | ||
expect(customProp('new-prop')).toEqual(27); | ||
}); | ||
|
||
it('should bind to both directives and properties', () { | ||
registerElement('tests-double', {}); | ||
_.compile('<tests-double ng-bind bind-ng-bind="\'hello\'"></tests-double>'); | ||
_.rootScope.apply(); | ||
expect(customProp('ng-bind')).toEqual("hello"); | ||
expect(_.rootElement).toHaveText('hello'); | ||
}); | ||
}); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
<label>Change the value through an ng-model bound input box: <input type="text" ng-model="curValue"></label>
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.
done