小编UX *_*Guy的帖子

如何在指令链接中访问父作用域

因此,在角度文档网站上,您可以定义Tobias和Jeff

angular.module('docsTransclusionExample', [])
.controller('Controller', ['$scope', function($scope) {
  $scope.name = 'Tobias';
}])
.directive('myDialog', function() {
  return {
   restrict: 'E',
    transclude: true,
    scope: {},
    templateUrl: 'my-dialog.html',
    link: function (scope, element) {
      scope.name = 'Jeff';
    }
  };
});
Run Code Online (Sandbox Code Playgroud)

如果你这样做,那么名字就是{{name}}

The name is Tobias
Run Code Online (Sandbox Code Playgroud)

我正在尝试通过链接功能访问Tobias.从链接函数内部,我如何获得$ scope.name值等于Tobias?

angularjs

6
推荐指数
2
解决办法
4879
查看次数

findOne 有效,但无法获取全部/查找

findOne 工作正常

db.collection('updates', function (err, collection) {
        collection.findOne({
            author: req.user._id
        }, function (err, doc) {
        }
 });
Run Code Online (Sandbox Code Playgroud)

我正在尝试获取所有文档,而不仅仅是一份。我正在更改 findOne 以查找(如下所示),但它不起作用。我该如何解决?

        db.updates.find({
            author: req.user._id
        }, function (err, doc) {
        }
Run Code Online (Sandbox Code Playgroud)

错误消息:它说无法调用未定义的方法“find”,这意味着该集合未被识别。

更新:这也不起作用:

db.collection('updates', function (err, collection) {
        collection.find({ //changed findOne to find
            author: req.user._id
        }, function (err, doc) {
        }
 });
Run Code Online (Sandbox Code Playgroud)

mongodb node.js

4
推荐指数
1
解决办法
1504
查看次数

为什么我不能将角度变量作为函数参数传递?

我试图通过followPerson()函数传递跟随者.如果我跟随Perers(123),这可以正常工作.但是,当我跟随角色({{follower.follower}})时,它不会发射.

{{follower.follower}}绝对有效,因为它以粗体显示.

<div ng-repeat="follower in followers.followers">
    <b>{{follower.follower}}</b>
    <a ng-click="followPerson({{follower.follower}})">Follow</a> 
</div>
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-scope angularjs-ng-repeat

0
推荐指数
1
解决办法
638
查看次数