Angular中的子字符串功能
我想根据url设置真/假条件。假设我的url有Angular中的子字符串功能,angular,Angular,我想根据url设置真/假条件。假设我的url有/test/demo我想将我的条件设置为true如果没有,我想将其设置为false。有什么解决方案吗?您可以尝试以下方法: let x = window.location.href.indexOf("/test/demo") !== -1 (在评论之后进行的编辑)const x=the_uri=='/test/demo'您使用的是角度,您可以传递每条路线的数据,最好检查数据
/test/demo
我想将我的条件设置为true
如果没有,我想将其设置为false
。有什么解决方案吗?您可以尝试以下方法:
let x = window.location.href.indexOf("/test/demo") !== -1
(在评论之后进行的编辑)
const x=the_uri=='/test/demo'代码>您使用的是角度,您可以传递每条路线的数据,最好检查数据