我在app.js中使用以下函数在后退/前进浏览器按钮/键盘的情况下有条件地更改dom元素:
angular.module('myApp')
.run(function ($rootScope, $location) {
$rootScope.$watch(function() {
if ( !$location.path().match(/\/$/) ) {
//dom changes
}
},
true);
});
我想添加另一个条件语句来做其他事情:
if ( navigator.userAgent.match(/iPhone/) ) {
//other stuff
}
但无论我在哪里尝试插入它,它都会破坏脚本。我如何将其链接到与先前的陈述不冲突?
编辑:只是为了澄清,它不打算先修改if语句。
由于