我正在进行角度2最终版本.
我已经宣布了两个模块:主应用程序和一个用于设置页面.
该主模块被宣布全球管道.该模块还包括设置模块.
app.module.ts
@NgModule({
imports: [BrowserModule, HttpModule, routing, FormsModule, SettingsModule],
declarations: [AppComponent, JsonStringifyPipe],
bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)
settings.module.ts
@NgModule({
imports: [CommonModule, HttpModule, FormsModule, routing],
declarations: [SettingsComponent],
exports: [SettingsComponent],
providers: []
})
export class SettingsModule { }
Run Code Online (Sandbox Code Playgroud)
当尝试在设置模块中使用管道时,我收到一条错误,指出无法找到管道.
zone.min.js?cb=bdf3d3f:1 Unhandled Promise rejection: Template parse errors:
The pipe 'jsonStringify' could not be found (" <td>{{user.name}}</td>
<td>{{user.email}}</td>
<td>[ERROR ->]{{user | jsonStringify}}</td>
<td>{{ user.registered }}</td>
</tr"): ManageSettingsComponent@44:24 ; …
Run Code Online (Sandbox Code Playgroud) 我有一个嵌入了youtube视频的网站.我得到以下错误,但我不知道为什么.我没有为chrome开发任何应用程序.它只是一个带视频的网站.
我得到的错误如下:
Failed to load resource: net::ERR_FAILED chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/cast_sender.js
Failed to load resource: net::ERR_FAILED chrome-extension://dliochdbjfkdbacpmhlcpmleaejidimm/cast_sender.js
Failed to load resource: net::ERR_FAILED chrome-extension://hfaagokkkhdbgiakmmlclaapfelnkoah/cast_sender.js
Failed to load resource: net::ERR_FAILED chrome-extension://fmfcbgogabcbclcofgocippekhfcmgfj/cast_sender.js
Failed to load resource: net::ERR_FAILED chrome-extension://enhhojjnijigcajfphajepfemndkmdlo/cast_sender.js
Run Code Online (Sandbox Code Playgroud)
有关如何避免这些错误的任何想法?
我试图运行CasperJS有PhantomJS#2.0.0一对MAC(优胜美地).当尝试运行CasperJS时,我收到以下消息:
"CasperJS needs PhantomJS v1.x
/usr/local/Cellar/casperjs/1.1-beta3/libexec/bin/bootstrap.js:91 in __die"
Run Code Online (Sandbox Code Playgroud)
我该如何让它运行?有没有人让它工作?
我一直在努力使用.bind()方法使用这些"this"并使用变量"self = this".在获得两个不同的结果时,我错过了一个概念.案例如下:
// Defining a callback class to use after retrieving data
var Callback = (function(){
// UPDATED!! Local vbles
var template_to_use, html_element, self;
function Callback(){
self = this,
template_to_use = null,
html_element = null;
}
var p = Callback.prototype;
p.set_template = function(template_funct){
self.template_to_use = template_funct;
};
p.set_html_element = function(html_element){
self.html_element = html_element;
};
p.use_callback = function(data){
$(self.html_element).append(self.template_to_use(data));
};
return Callback;
})();
Run Code Online (Sandbox Code Playgroud)
该功能的用法如下:
// Setup callback 1 to call after getting the data
var callback_1 = new Callback();
callback_1.set_template(use_templ_1); …
Run Code Online (Sandbox Code Playgroud) 我正在使用处理程序栏来创建模板.假设我正在做一个TODO列表.我有一个集合,我还需要支持添加相同风格的新TODO元素.
到目前为止,我有一个TODO模板集合:
<script id="TODO-collection-templ" type="text/x-handlerbars-template">
<div id="collection">
<ul>
{{#list todos}}
<li><span>{{this.title}}</span><span>{{this.description}}</span></li>
{{/list}}
</ul>
</div>
</script>
Run Code Online (Sandbox Code Playgroud)
如果我想添加新元素,那么(对我来说)唯一的方法就是创建另一个构建以下内容的模板:
<script id="TODO-templ" type="text/x-handlerbars-template">
<li><span>{{title}}</span><span>{{description}}</span></li>
</script>
Run Code Online (Sandbox Code Playgroud)
所以我最终得到了两个模板,但是那些容易出错(如果我在TODO-collection-templ中改变了一些内容而忘记对TODO-templ进行相同的更改,它将无法正确呈现Html)
有没有办法在TODO-collection-templ中包含TODO-templ?
我不确定我是否正确理解了observable的工作方式以及如何从挂载的标签中获取引用.我有一个组件.在这个组件中,我们有一个组件和一个组件.目的是避免组件之间的耦合.因此,我希望我的搜索组件在搜索完成时触发事件(单击一个按钮).此事件应由组件捕获,该组件将根据搜索过滤集合数据.
index.html文件使用以下方法加载标记:
的index.html
riot.mount(".content", "page", null);
Run Code Online (Sandbox Code Playgroud)
该页面定义如下:
page.js
<page>
<!-- Search tag controls -->
<search id="searchTag"></search>
<!-- Collection data to display -->
<collection id="collectionTag"></collection>
</page>
Run Code Online (Sandbox Code Playgroud)
组件脚本简要定义如下:
search.js
var self = this;
riot.observable(self);
<!-- This function is called when the user click on the button. -->
self.filtering = function()
{
<!-- We get data from inputs -->
var info = Getting data from inputs;
<!-- Trigger the event hoping …
Run Code Online (Sandbox Code Playgroud) 我试图在节点上执行bower安装:4.1.2来自dockerfile的docker 容器.
我的dockerfile的一部分是这样的:
#Install bower to command line
RUN npm install -g bower
# Define the host folder that will contain the code
WORKDIR /application
# Copy src to application host folder**
ADD . /application
# RUN move to /application/public/webapp where there is a bower.json file and install it**
RUN cd public/webapp && bower install --allow-root --config.interactive=false
ENTRYPOINT ["npm"]
CMD ["start"]
Run Code Online (Sandbox Code Playgroud)
我建立它并且建立它.
尽管显示以下内容,但此dockerfile不会构建bower_components文件夹:
Step 9 : RUN cd public/webapp && …
Run Code Online (Sandbox Code Playgroud) 我在 e2e 中使用 Nightwatch,鉴于它们附带的名称和解释,我发现这两个命令有点令人困惑。
.waitForElementVisible: 在执行任何其他命令或断言之前,等待元素在页面中可见的给定时间(以毫秒为单位)。
可见的含义是什么?
display:hidden
, position:relative; left:20000px;
, ...?用户实际上并不可见,但 dom 基本上是存在的。.waitForElementPresent: 在执行任何其他命令或断言之前,等待元素出现在页面中的给定时间(以毫秒为单位)。
是什么意思本?
这两个命令之间有任何关系/含义吗?
很多问题,但也许对它们如何工作的解释可以解决所有这些小问题......
有时我只是收到错误,我想这可能是我对这两个命令的理解不好。
我试图了解flatMap的工作原理.我知道这是一种处理Observable <Observable <T >>的方法.
无论如何,我正在测试它的行为并且坚持这个:
let plusDom = document.querySelector('#plus');
let minusDom = document.querySelector('#minus');
let minusSource = Rx
.Observable
.fromEvent(minusDom, 'click');
let plusSource = Rx.Observable
.fromEvent(plusDom, 'click');
plusSource
.flatMap(function(c){
console.log('Flatmap called');
return minusSource;
})
.subscribe(function(e){
console.log('done');
})
Run Code Online (Sandbox Code Playgroud)
这里是jsbin:https://jsbin.com/sefoyowuqe/edit ? html,js,console,output
我不明白这种行为:
3 clicks on plusDom prints:
Flatmap called
Flatmap called
Flatmap called
Run Code Online (Sandbox Code Playgroud)
1单击minusDom打印:
done
done
done
Run Code Online (Sandbox Code Playgroud)
为什么在点击minusDom时,它会像点击plusDom那样多次重放事件?
我正在研究Angular 2.0(是的,有点落后于当前的2.4).
我有一个复选框列表.我试图在未检查到最后的复选框时检查所有的复选框.
HTML
<div *ngFor="let filter of filters">
<label htmlFor="check-box-{{filter.text}}"
[ngClass]="(filter.selected)? 'active' : '' ">
<input type="checkbox"
name="check-box-{{filter.text}}"
[checked]="filter.selected"
(change)="onSelectFilter(filter)"
attr.id="check-box-{{filter.text}}">
{{filter.selected}} - ({{filter.counter}})
</label>
</div>
Run Code Online (Sandbox Code Playgroud)
TS
onSelectFilter(filter: Filter){
filter.toggleSelection();
let isAnyFilterSelected = this.filters.find(filter => filter.selected);
// If no filter is selected then ALL filters are selected
if(!isAnyFilterSelected){
this.filters.forEach(filter => filter.selected = true );
}
}
Run Code Online (Sandbox Code Playgroud)
我为它创造了一个plunker.
https://plnkr.co/edit/uzF6Lk5fxRZjXBOaS9ob?p=preview
如果取消选中CHECKED属性为TRUE的唯一复选框,我希望所有复选框都具有CHECKED属性.这不会发生.
有任何想法吗?
javascript ×3
angular ×2
casperjs ×1
checkbox ×1
chromecast ×1
docker ×1
dockerfile ×1
html ×1
jquery ×1
phantomjs ×1
riot.js ×1
rxjs ×1
youtube ×1