Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = angular.module("test", []);
- app.component("test", {
- bindings: {
- "contactId": "<"
- },
- controllerAs: "model",
- controller: () => {
- //output: 'contact id from controller: undefined'
- console.log(`contact id from controller: ${this.contactId}`);
- },
- template: "<div>Contact id from view: {{model.contactId}}</div>"
- });
- <test contact-id="8"></test>
- app.component("test", {
- bindings: {
- "myContactId": "<"
- }
- }
- <test my-contact-id="8"></test>
- var app = angular.module("test", []);
- app.component("test", {
- bindings: {
- "contactId": "<"
- },
- controllerAs: "model",
- controller: ($scope) => {
- var model = $scope.model;
- alert(`contact id from controller: ${model.contactId}`);
- },
- template: "<div>Contact id from view: {{model.contactId}}</div>"
- });
- controller: function() {
- alert('contact id from controller: ' + this.contactId);
- }
- app.component("test", {
- bindings: {
- "myContactId": "<"
- },
- controller:function(){
- var self=this;
- this.$onInit=function(){
- // do all your initializations here.
- // create a local scope object for this component only. always update that scope with bindings. and use that in views also.
- self.myScopeObject=self.myContactId
- }
- },
- template:'<p>{{$ctrl.myScopeObject}}</p>'
- }
- <test my-contact-id="8"></test>
- bindings:{
- value:'@',
- object:'<', // also known as one-way
- twoWay:'='
- }
- $scope.$ctrl.contactId
- /*bindings: {
- modalInstance: '<',
- resolve: '<'
- },*/
- scope: {
- modalInstance: '<',
- resolve: '<'
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement