angularJS有范围内的数据,但我无法得到它们?

时间:2015-05-24 13:04:49

标签: javascript angularjs angularjs-directive

我写了一个指令,$ scope中有 public override void Up() { DropTable("dbo.UserLogin"); CreateTable( "dbo.UserLogin", c => new { LoginProvider = c.String(nullable: false, maxLength: 128), ProviderKey = c.String(nullable: false, maxLength: 128), UserId = c.Int(nullable: false), }) .PrimaryKey(t => new { t.LoginProvider, t.ProviderKey, t.UserId }) .ForeignKey("dbo.User", t => t.UserId, cascadeDelete: true) .Index(t => t.UserId); } public override void Down() { DropTable("dbo.UserLogin"); CreateTable( "dbo.UserLogin", c => new { Id = c.Int(nullable: false, identity: true), LoginProvider = c.String(), ProviderKey = c.String(), UserId = c.Int(nullable: false), }) .PrimaryKey(t => t.Id) .ForeignKey("dbo.User", t => t.UserId, cascadeDelete: true) .Index(t => t.UserId); } ,但在我的指令中,在data函数中,我可以使用link获取数据 但我是console.log(范围),范围内确实有scope.data,但我无法获得data

有directive.js:

data

导致带有chrome的控制台:

  todoApp.directive('planProgress', function() {
    return {
      scope: false,
      link: function(scope, elem, attrs) {
        console.log(scope);
        attrs.$set('value', 10);
        attrs.$set('total', 20);
        elem.progress();
      }
    };
  });

但如果我在directive.js中data: Array[3] ,则在console.log中为console.log(scope.data) 我不知道为什么,可以指示继承控制器吗?

0 个答案:

没有答案