嗨,我是非常新的ember js.我在模板中的链接到动作上传递动作参数(id)但我没有在我的控制器中获取值.
我的模板代码如下:
index.html的:
<script type="text/x-handlebars" data-template-name="search">
{{#each model.results}}
// here i pass id value along with action
{{#link-to 'profile' id action="profileinfo"}}
</script>
Run Code Online (Sandbox Code Playgroud)
app.js:
App.SearchController = Ember.ObjectController.extend({
id: '',
actions:{
profileinfo: function(id){
// Here i access id value like this
console.log(id);
var id = this.get('id');})
Run Code Online (Sandbox Code Playgroud)
当我点击链接动作转到Searchcontroller,但我得到id值为空.我在堆栈溢出中遵循一些解决方案,但不幸的是我没有得到任何东西.请提供一些解决方案
嗨,我是非常新的ember js.我为新员工输入了一个表格,并通过route.Data发送数据成功保存.但问题是在表单提交后我的表单数据没有被清除.
App.Router.map(function() {
this.resource('saveprofile', { path: '/saveprofile/:profiledata'});
});
App.NewprofileController = Ember.ObjectController.extend({
id:'',
name: '',
designation: '',
saveProfileAction: function () {
profiledata = [{ "id": this.get("id")},
{"name": this.get("name")},
{"designation": this.get("designation")}]
pdata = $.ajax({
type: "POST",
dataType: "json",
url: "/saveprofile?profiledata=" +profiledata,
data: JSON.stringify(profiledata),
dataType: "json",
async: false}).done(function() {
$.bootstrapGrowl("Employee added successfully", {
type: 'success',
align: 'center',
width: '1000',
allow_dismiss: false
}).responseJSON
})
});
console.log(pdata)
}
});
App.SaveProfileRoute = Ember.Route.extend({
model: function(params) {
console.log(params);
return Ember.$.getJSON( "/saveprofile?profiledata=" + params.profiledata);
}, …Run Code Online (Sandbox Code Playgroud)