我有一个Angular 6 SPA。该应用程序会定期在iframe中进行后台操作(以静默方式刷新OAuth令牌)。每次我的应用程序执行此操作时,它都会重定向到“ /”路由。这是不受欢迎的行为,原因是如果用户在填写表单的过程中会丢失自己的表单并被重定向。
我认为重定向是由于代码中的某些内容而发生的;也许是后卫。有没有办法确定Angular中路由重定向的来源?
答案 0 :(得分:1)
您可以使用enableTracing启用调试模式以进行角度路由
@Override
public View getView(final int position, View v, ViewGroup viewGroup) {
decimalFormat = new DecimalFormat("###,##0.00");
dbHelper = new DBHelper(c);
sqldb = dbHelper.getWritableDatabase();
dbManager = new DBManager(c);
dbManager.open();
getTripDetails();
if (v == null) {
v = LayoutInflater.from(c).inflate(R.layout.item_payment, viewGroup, false);
viewHolder = new PaymentList2ViewHolder(v);
v.setTag(viewHolder);
} else {
viewHolder = (PaymentList2ViewHolder) v.getTag();
}
if (getCount() == 0) {
viewGroup.removeAllViews();
} else {
Payment2Item s = (Payment2Item) getItem(position);
viewHolder.tvId.setText(s.getSeatID());
viewHolder.tvSeatNo.setText(s.getSeatNo());
viewHolder.tvPassengerName.setText(s.getfName() + " " + s.getlName());
viewHolder.tvPassengerType.setText(s.getPassengerType());
viewHolder.tvFareAmount.setText(s.getFare());
viewHolder.txtAmountToPay.setText(s.getPayment());
viewHolder.tvDiscountedAmount.setText(s.getDiscount());
JSONObject dataObject = null;
try {
dataObject = objAllSched.getJSONObject("data");
JSONArray schedArray = dataObject.getJSONArray("schedules");
Log.e("schedArray", String.valueOf(schedArray));
if (dataObject.length() != 0) {
for (int i = 0; i < schedArray.length(); i++) {
JSONObject object = schedArray.getJSONObject(i);
String id = null;
id = object.getString("id");
Log.e("object ", String.valueOf(object));
if (id.toString().equalsIgnoreCase(scheduleId)) {
JSONArray faresArray = object.getJSONArray("fares");
Log.e("fare array", String.valueOf(faresArray));
for (int sab = 0; sab < faresArray.length(); sab++) {
JSONObject object2 = faresArray.getJSONObject(sab);
String name = null;
name = object2.getString("name");
if (s.getPassengerType().equalsIgnoreCase(name)) {
price = Double.parseDouble(object2.getString("price"));
viewHolder.tvFareAmount.setText(decimalFormat.format(price));
viewHolder.txtAmountToPay.setText(decimalFormat.format(price));
}
}
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
/*viewHolder.txtAmountToPay.setText(itemArrayPayment2List.get(position).getPayment());
viewHolder.txtAmountToPay.setId(position);
viewHolder.txtAmountToPay.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Double firstValue = TextUtils.isEmpty(viewHolder.tvFareAmount.getText().toString().trim().replace(",", "")) ? 0 :
Double.parseDouble(viewHolder.tvFareAmount.getText().toString().trim().replace(",", ""));
Double secondValue = TextUtils.isEmpty(viewHolder.txtAmountToPay.getText().toString().trim().replace(",", "")) ? 0 :
Double.parseDouble(viewHolder.txtAmountToPay.getText().toString().trim().replace(",", ""));
Double answer = firstValue - secondValue;
}
@Override
public void afterTextChanged(Editable s) {
}
});*/
return v;
}
public class PaymentList2ViewHolder {
TextView tvId, tvSeatNo, tvPassengerName, tvPassengerType, tvFareAmount, tvDiscountedAmount;
EditText txtAmountToPay;
PaymentList2ViewHolder(View v) {
tvId = v.findViewById(R.id.tvId);
tvSeatNo = v.findViewById(R.id.tvSeatNo);
tvPassengerName = v.findViewById(R.id.tvPassengerName);
tvPassengerType = v.findViewById(R.id.tvPassengerType);
tvFareAmount = v.findViewById(R.id.tvFareAmount);
tvDiscountedAmount = v.findViewById(R.id.tvDiscountedAmount);
txtAmountToPay = v.findViewById(R.id.txtAmountToPay);
//v.setTag(viewHolder);
}
}
使用路由时,您将看到应用程序中正在运行许多事件。因此,您可以更轻松地进行调试。希望有帮助。