我试图将$ 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
不是变量名本身.
在内部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
)
我想检测我的Chrome应用程序是否有焦点.根据输出我想要显示一个简单的"吐司"或显示一个chrome.notifications.create
.
要么我做了一些可怕的错误,要么聚合物不喜欢我.见如下:
<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
.所以,如果有人能告诉我哪里出错了会很棒!
我无法形成一个grep正则表达式,它只会找到那些以+符号结尾的行.例:
应该匹配 - This is a sample line +
不应该匹配 - This is another with + in between
或This is another with + in between and ends with +