Reputation: 943
I create a template and it's controller and i set a variable(value) in controller but when i try to access in template noting to happen. my controller is:
App.AboutController = Ember.Controller.extend({
info:null,
init: function() {
console.log("yes i am in About controller");
info = post["about"];
},
actions: {
getdata1:function(data){
console.log("get data",data);
info = post[data];
console.log(info);
}
}
and Template is:
<script type="text/x-handlebars" id="about" data-template-name="about">
<div class="col-xs-6 middlesubBody">
{{info}}
</div>
<div class="col-xs-3 rightsubBody">
<div id="column">
<div
{{action "getdata1" "about"}}> About</div>
<div>
</div>
</script>
MY Action is working fine but info value is not set to template.i want to dynamic binding . I think i am wrong but i don't know where is problem.
Upvotes: 0
Views: 158
Reputation: 18680
You need to use this.set('info', value)
instead of info = value
. Also, you use post
many times, but it isn't defined anywhere. I have to assume that you have defined it somewhere:
App.AboutController = Ember.Controller.extend({
info: null,
init: function() {
console.log("yes i am in About controller");
this.set('info', post["about"]);
this._super(); // you need this to avoid unexpected behavior
},
actions: {
getdata1: function(data) {
console.log("get data",data);
this.set('info', post[data]);
console.log(this.get('info'));
}
}
});
Upvotes: 1