on 01-19-2015 10:59 PM
Hello Everyone,
I am trying to send the data from one view to another using routing but when I am writing the code its not sending the parameters which I am defining in the navTo function below is the code which I am trying to use .
edit : function(evt){
sap.ui.core.UIComponent.getRouterFor(this).navTo("app",{id : "5"});
}
as shown above I am trying to send the id to the view app but in the init method of app view I am not getting the argument id its showing as undefined.
below is the code for init method
sap.ui.core.UIComponent.getRouterFor(this).attachRouteMatched(function(oEvent){
console.log(oEvent.getParameter("arguments").id);
if(oEvent.getParameter("name") === "app"){
var context = new sap.ui.model.Context(view.getModel(),oEvent.getParameter("arguments").id);
alert(context+"hello");
}
},this);
when I am trying to run the above code its showing me as undefined in the alert box.
So can anyone help me out where I am making a mistake .
Thanks in advance,
Anshul D
Hi Anshul,
Do you have the argument "id" mentioned in the pattern "app" in the routes of your component.js file.
It shoud be something like this
pattern : "{product}/:tab:",
name : "product",
view : "Detail"
Look at the developer guide - Step 3: Navigation and Routing - SAPUI5 SDK - Demo Kit
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Kedar,
yes I have not defined that in component.js but I have one doubt I'll define this in sub route right ??
below is the code
{ pattern : "app",
name : "app",
view : "app",
subroutes : [
{
pattern:"{id}",
name:"app2",
view : "app2"
}
]
is the above code correct or do I need to add target control and target aggregation
Thanks,
Anshul
Yes, You would need to define targetAggregation and the other thing which i saw in your subroute you mentioned "{id}" as the pattern. If you do not have a pattern for the subroute then change this to something like this
pattern: "sub/{id}"
Also i am not sure why would you use subroute if you have just navigate to a single view/page.
Hope this helps.
try just oEvent.getParameter("id") in attachRouteMatched handler
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.