为什么页面跳转不正确?

两个不同权限对应两个不用页面
前面的http.post服务已经success下面开始是success下面的代码
alert(data.roles[0]);//这是提示权限
if (data.roles[0] = "inpector")

                {
                    $window.location.href = "lcdFaultInsert.html";
                }
                else
                {
                    $window.location.href = "faultDeviceInsert.html";
                } 

两个不同账号登录在alert那里确实是不同的权限,但是页面跳转却都是进第一个页面?请问怎么解决?

阅读 2.6k
4 个回答
if (data.roles[0] == "inpector")

注意是==

if (data.roles[0] = "inpector")这是个赋值

if (data.roles[0] = "inpector")

if 里面你用 ===...

== 不是 =

推荐问题