Javascript / AngularJS / NodeJS – 检查重复?
我有一个非常棘手的错误….
我将数据传递给一个函数。 该function要做的是获取这些数据,并确保数据不存在于另一个页面上。 在另一个页面上的数据是一个数组,如果没有任何内容给未定义。 我想要做什么的想法如下:
if($scope.profile.x.VALUE_IN_UNDEFINED_ARR_X === undefined) { //AKA theres nothing in the profile yet...add to users profile } else { if($scope.profile.x.name === myData.name) { //now theres a duplicate found } else { //add to users profile } }
我似乎无法得到像这样的工作。 对我来说,它总是在第一个if语句(undefined)中执行代码。 然后继续添加重复项。
我希望你们也许可以帮我写一个可以解决这个问题的循环。
谢谢
使用typeof
来检查未定义
typeof $scope.profile.x.VALUE_IN_UNDEFINED_ARR_X == 'undefined'
另外,“configuration文件中没有任何内容”可以解释为“ $scope.profile
is undefined”,如果是这样,你应该检查这个
typeof $scope.profile == 'undefined'
- 如何在Morris JSgraphics的Angular JS中创build一个指令
- ng重新安装应用程序后,无法写入EPERM(无法写入)
- 如何使用MEAN堆栈在注册时显示失败消息
- 如何在同一个Angular JS App中使用不同的API和不同的authentication头
- 如何查看第一个Angular模板?
- 如何解决错误“请设置envvariablesCHROME_BIN”运行Angular.js与咕噜声
- 如何将MEAN堆栈部署到我的托pipe服务器?
- angular度抛出错误$ parse:ueoe意外的expression式结尾
- 在Webstorm中一次性debuggingAngularJS和NodeJS(没有CORS)