Skip to content

Instantly share code, notes, and snippets.

@ahoef
Created January 21, 2016 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahoef/df91b536575e50531593 to your computer and use it in GitHub Desktop.
Save ahoef/df91b536575e50531593 to your computer and use it in GitHub Desktop.
Angular Controllers vs Components
//angular 1.x
//controller
angular.module('foo')
.controller('myMessage', function($scope) {
$scope.message = 'Look out for that rock!';
});
//view
<div ng-controller="myMessage">
{{ message }}
</div>
//angular 2 component with typescript
import { Component } from 'angular2/angular2';
@Component({
selector: 'message-widget',
templateUrl: `{{ message }}`,
inputs: ['message']
})
export class myMessage {
constructor(public message: string) {}
}
//angular 2 es5
var myMessage = ng.
Component({
selector: 'message-widget',
})
.View({
template: '{{ message }}'
})
.Class({
constructor: function(message) {
this.message = message;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment