小编Vik*_*hal的帖子

将变量的值传递给angularjs指令模板函数

我试图将$ scope的变量传递给指令,但它不起作用.我在模板函数中捕获变量:

app.directive('customdir', function () {

    return {
        restrict: 'E',

        template: function(element, attrs) {
            console.log(attrs.filterby);
            switch (attrs.filterby) {
                case 'World':
                    return '<input type="checkbox">';
            }
            return '<input type="text" />';
        }
    };
});
Run Code Online (Sandbox Code Playgroud)

我需要的是变量的值而filterby不是变量名本身.

Plunkr演示

javascript angularjs

12
推荐指数
2
解决办法
5万
查看次数

输入文本中的ng-bind-html不绑定

在内部ng-repeat,以下代码不起作用:

<input type="text" ng-bind-html="row.value" />
Run Code Online (Sandbox Code Playgroud)

以下是:

<span ng-bind-html="row.value"></span>
Run Code Online (Sandbox Code Playgroud)

我猜ng-bind-html是无法绑定到一个input元素?

也没有ng-bind-html实际的元素与模型绑定(在这里row.value)

angularjs ng-bind-html

6
推荐指数
1
解决办法
4153
查看次数

如何检测我的Chrome应用程序是否聚焦?

我想检测我的Chrome应用程序是否有焦点.根据输出我想要显示一个简单的"吐司"或显示一个chrome.notifications.create.

google-chrome-app

5
推荐指数
0
解决办法
60
查看次数

Polymer document.querySelector未按预期工作

要么我做了一些可怕的错误,要么聚合物不喜欢我.见如下:

<polymer-element name="menu-paper-ui" noscript>
 <template>
  <paper-dialog heading="Dialog" transition="paper-dialog-transition-bottom">
  [ .. ]
  </paper-dialog>
  <paper-button label="Dialog Bottom" on-tap="{{toggleDialog}}"></paper-button>

 </template>
 <script>
  Polymer('menu-paper-ui', { 
    toggleDialog : function() {
      var dialog = document.querySelector('paper-dialog');
      console.log(dialog); //returns null
      dialog.toggle();
    }
  })

 </script>
</polymer-element>
Run Code Online (Sandbox Code Playgroud)

现在,我有理由使用 querySelector.所以,如果有人能告诉我哪里出错了会很棒!

polymer

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

查找以"+"结尾的行

我无法形成一个grep正则表达式,它只会找到那些以+符号结尾的行.例:

应该匹配 - This is a sample line +

不应该匹配 - This is another with + in betweenThis is another with + in between and ends with +

grep

2
推荐指数
1
解决办法
625
查看次数