Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/422.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 角度过滤器:小提琴和我的代码有不同的结果_Javascript_Angularjs - Fatal编程技术网

Javascript 角度过滤器:小提琴和我的代码有不同的结果

Javascript 角度过滤器:小提琴和我的代码有不同的结果,javascript,angularjs,Javascript,Angularjs,我正试图在我的mean.io项目中构建一个过滤器。当我遇到问题时,我用小提琴做了一个简单的版本来测试它 但是小提琴过滤器工作得很好,而不是我的项目 这是我的小提琴: 这是我的项目代码: {{global.user._id}} <!-- Working ok, I get the good user Id --> <div class="articles list-group liste-articles"> <a data-ng-

我正试图在我的mean.io项目中构建一个过滤器。当我遇到问题时,我用小提琴做了一个简单的版本来测试它

但是小提琴过滤器工作得很好,而不是我的项目

这是我的小提琴:

这是我的项目代码:

 {{global.user._id}} <!-- Working ok, I get the good user Id -->
  <div class="articles list-group liste-articles">
     <a data-ng-repeat="art in articles | contains:global.searchText | filter:{ 'user._id': global.user._id}:true" ng-click="selectByArticle(art)" class="list-group-item lien-article" ng-class="{sel: art._id == article._id}">
     {{art.user._id}}</a> <!-- Working ok, I get the good article.user Id -->
  </div>
我的模型是:

第条:

var ArticleSchema = new Schema({
  created: {
    type: Date,
    default: Date.now
  },
  title: {
    type: String,
    trim: true
  },
  content: {
    type: String,
    required: true,
    trim: true
  },
  user: {
    type: Schema.ObjectId,
    ref: 'User'
  },
  images : []
});
用户:


您是否在小提琴中使用与实际项目相同的AngularJS版本?同样,在项目代码中,您使用了contains过滤器,但您的fiddle没有这个过滤器。您应该发布该过滤器的代码,它很可能是罪魁祸首。遗憾的是,如果您显示的代码正常工作,我们将无法帮助您。试着通过逐步缩小你的研究范围来发现问题。我已经在没有第二个过滤器的情况下进行了测试,仍然使用相同的pb。我使用的是angular v1.3.2版本的Lackhole,我尝试过这样做,但这里的版本与小提琴上的版本完全相同。我看到的主要区别是,我使用global$scope编辑我的文章,并提供更多信息。是否有方法显示或测试以下内容:筛选器:{'user.\u id':global.user.\u id}:true??
var ArticleSchema = new Schema({
  created: {
    type: Date,
    default: Date.now
  },
  title: {
    type: String,
    trim: true
  },
  content: {
    type: String,
    required: true,
    trim: true
  },
  user: {
    type: Schema.ObjectId,
    ref: 'User'
  },
  images : []
});
var UserSchema = new Schema({
  name: {
    type: String,
    required: true,
    get: escapeProperty
  },
  email: {
    type: String,
    required: true,
    unique: true
  
  },
  username: {
    type: String,
    unique: true,
    required: true,
    get: escapeProperty
  },
 [... etc ...]