我的项目中有UX设计,比如假设我有一个Register页面,所以我创建了一个带有html和css的Register组件,并给出了一个状态' localhost:8080 / register'即' /注册'作为路线。 在成功注册时,我想显示一个不同的HTML模板,用于注册一些路由统计信息" / register / done"但在这里我不想制作任何新组件,因此可以创建一个没有组件的路由。 第二种方法是我可以替换当前组件中的HTML模板以显示成功注册确认屏幕。那么是否可以动态更改HTML模板。当我使用webpack时,我想不到。
如果有任何其他解决方案显示这两个相关路线的HTML模板和路线不同,请在此处分享。
提前致谢!!
答案 0 :(得分:0)
使用标志动态更改html模板。 根据您的要求在register.component.ts中设置标志true或false。在html模板中使用' ngIf'在模板视图之间切换。
private void getLocation() {
try {
if (ActivityCompat.checkSelfPermission((Activity) mContext, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission((Activity) mContext, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
Constant.displayLogE(">> PErmission >> ", ">> not granted");
return;
} else {
mLocationManager = (LocationManager) mContext
.getSystemService(LOCATION_SERVICE);
// getting GPS status
boolean isGPSEnabled = mLocationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
// getting network status
boolean isNetworkEnabled = mLocationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (!isGPSEnabled && !isNetworkEnabled) {
// no network provider is enabled
} else {
if (isNetworkEnabled) {
mLocationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
0,
0, this);
if (mLocationManager != null) {
mLocation = mLocationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (mLocation != null) {
mCurrentLatitude = mLocation.getLatitude();
mCurrentLongitude = mLocation.getLongitude();
loadFilterListData();
}
}
} else if (isGPSEnabled) {
if (mLocation == null) {
mLocationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
0,
0, this);
if (mLocationManager != null) {
mLocation = mLocationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (mLocation != null) {
mCurrentLatitude = mLocation.getLatitude();
mCurrentLongitude = mLocation.getLongitude();
loadFilterListData();
}
}
}
}
if (mLocation == null) {
Constant.displayToast(mContext, "Location not fetched. Please, try again.");
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}

`
答案 1 :(得分:0)
I have solved it like you say but with optimized ngIf else in Angular 4. like following-
<div class="parent-div">
<div class="signup-center " *ngIf="!signUpDone; else confirm">
<div>Signup with emailid>
....Signup screen.....
</div>
</div>
<ng-template #confirm>
<div>Congratulations!! You have successfully created your account</div>
</ng-template>
</div>