AngularJS advanced () solves the problem of abnormal display caused by refreshing AngualrJS pages
Solve the Problem of abnormal display caused by refreshing the AngualrJS page
As the saying goes, Details determine success or failure, as does programming. During the programming process, we may unconsciously ignore some details, but we do not know that these details are exactly the cause of the page display problems. I will give you an example here.
After the page is loaded normally, it is displayed as follows:
After you press F5 to refresh, the page is shown as follows:
Obviously, an exception is displayed on the page. Let's look at the Chrome error prompt,
The Code is as follows:
The above Code leads to errors.
Tracing
Let's review how errors occur. Normal page display is easy to understand when the page is loaded normally. The program follows the established data stream. However, after you press F5 to refresh it, $ stateParams. uid does not exist. If you call it again, the undefined error will occur, causing an exception in page loading.
How can this problem be solved?
First, you should add a variable judgment statement before the statement execution. If the variable exists and is not empty, you can continue to execute other processes. The Code is as follows: <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + forward/K/b7d19zK/TwvcD4KPHA + forward/X3NKzyv08L3A + cjxwp1_vcd4kpha + forward = "" & $ stateParams. uid! = Null & typeof (instance. shopStatementDtl )! = "Undefined ")
{
.................
.................
}
Effect after execution:
Meiwenmeitu