Skip to content

Instantly share code, notes, and snippets.

@joeeames
Created June 21, 2015 19:33
Show Gist options
  • Save joeeames/f2323ea4d6aedc9c7354 to your computer and use it in GitHub Desktop.
Save joeeames/f2323ea4d6aedc9c7354 to your computer and use it in GitHub Desktop.
<div>
<div [hidden]='!collapsed()' (click)="collapseAddress()">
<h4>1 Address:</h4>
{{user.address.street}} <br />
{{user.address.city}}<br />
{{user.address.planet}}
</div>
<div [hidden]='collapsed()' (click)="expandAddress()">
<h4>2 Address:</h4>
{{user.address.planet}}...
</div>
</div>
import {Component, View, bootstrap, Attribute} from "angular2/angular2";
@Component({
selector: 'collapsable-address',
// properties: {
// 'address' : 'address'
// }
bind: {
address: 'address'
}
})
@View({
templateUrl: './templates/collapsable-address.html'
})
export class CollapsableAddress {
constructor() {
this.isCollapsed = false;
console.log(this.address);
}
collapsed() {
console.log(1);
return false;
// return this.isCollapsed;
}
expandAddress() {
console.log(2);
this.isCollapsed = !this.isCollapsed;
}
collapseAddress() {
console.log(3);
this.isCollapsed = !this.isCollapsed;
}
}
<div>
<h1>Hello {{ name }}</h1>
{{users}}
<div *ng-for="#user of users">
<collapsable-address [thedata]="hi"></collapsable-address>
USER: {{user}}
</div>
</div>
import {NgFor, Component, View, bootstrap, Attribute} from "angular2/angular2";
import {users} from "./users"
import {CollapsableAddress} from "./collapsableAddress";
// console.log(users);
// console.log(CollapsableAddress);
console.log(NgFor);
@Component({
selector: 'my-app' // Defines the <my-app></my-app> tag
})
@View({
templateUrl: './templates/main.html', // Defines the inline template for the component
directives: [CollapsableAddress, NgFor]
})
class MyAppComponent {
name: string;
constructor() {
this.users = [1,2,3];
// this.users = users;
console.log(this.users);
}
}
bootstrap(MyAppComponent).then(function(success) {
console.log(success);
}, function(err) {
console.log(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment