我觉得我错过了什么。当我尝试在我的模板中使用数据属性时,像这样:

<ol class="viewer-nav">
    <li *ngFor="#section of sections" data-sectionvalue="{{ section.value }}">
        {{ section.text }}
    </li>
</ol>

Angular 2会崩溃:

例外:模板解析错误:不能绑定到'sectionvalue',因为 它不是已知的本地财产(” ] data-sectionvalue = "{{部分。值}}">{{section。文本}}

我显然在语法上遗漏了一些东西,请帮助。

我用WPF c#编程。我有如下路径:

C:\Program Files\hello.txt

我想从中提取hello。

路径是从数据库中检索的字符串。目前,我正在使用以下代码通过'\'分割路径,然后再次通过'.'分割:

string path = "C:\\Program Files\\hello.txt";
string[] pathArr = path.Split('\\');
string[] fileArr = pathArr.Last().Split('.');
string fileName = fileArr.Last().ToString();

这是可行的,但我相信应该有更简单、更聪明的解决方案。任何想法?

是否已经开发了使用setAttribute代替点(.)属性表示法的最佳实践?

例如:

myObj.setAttribute("className", "nameOfClass");
myObj.setAttribute("id", "someID");

or

myObj.className = "nameOfClass";
myObj.id = "someID";

考虑一下——基类a,类B继承自a,类C继承自B,在初始化器中调用父类初始化器的通用方法是什么?如果这听起来仍然太模糊,这里有一些代码。

class A(object):
    def __init__(self):
        print "Initialiser A was called"

class B(A):
    def __init__(self):
        super(B,self).__init__()
        print "Initialiser B was called"

class C(B):
    def __init__(self):
        super(C,self).__init__()
        print "Initialiser C was called"

c = C()

我现在就是这么做的。但它似乎还是有点太非泛型了——您仍然必须手动传递正确的类型。

现在,我尝试使用self。__class__作为super()的第一个参数,但是,显然它不起作用-如果你把它放在C的初始化式中-很好,B的初始化式会被调用。如果你在B中做同样的事情,“self”仍然指向C的一个实例,所以你最终再次调用B的初始化式(这以无限递归结束)。

目前没有必要考虑钻石继承的问题,我只是对解决这个具体问题感兴趣。

如果我向matplotlib图添加一个副标题,它会被副图的标题覆盖。有人知道怎么简单地处理吗?我尝试了tight_layout()函数,但它只会让事情变得更糟。

例子:

import numpy as np
import matplotlib.pyplot as plt

f = np.random.random(100)
g = np.random.random(100)
fig = plt.figure()
fig.suptitle('Long Suptitle', fontsize=24)
plt.subplot(121)
plt.plot(f)
plt.title('Very Long Title 1', fontsize=20)
plt.subplot(122)
plt.plot(g)
plt.title('Very Long Title 2', fontsize=20)
plt.tight_layout()
plt.show()

AtomicBoolean做了哪些volatile boolean不能做到的事情?

嗨,我正在与Redis一起使用Laravel。当我试图通过get方法访问一个键时,然后得到以下错误“对持有错误类型值的键进行操作”

我使用以下代码访问键值-

我使用这段代码从redis获取数据

$values = "l_messages";
$value = $redis->HGETALL($values);
print($value);

我想有一个垂直的菜单与特定的高度。

每个子元素必须填充父元素的高度,并且文本必须居中对齐。

子节点的数量是随机的,所以我必须使用动态值。

Div .container包含随机数量的子元素(.item),这些子元素总是要填充父元素的高度。为了实现这一点,我使用了flexbox。

为了使链接与文本对齐到中间,我使用显示:表格单元格技术。但是使用表格显示需要使用100%的高度。

我的问题是。item-inner {height: 100%}不工作在webkit (Chrome)。

有解决这个问题的方法吗? 或者有不同的技术,使所有的。item填充父的高度与文本垂直对齐到中间?

这里的例子jsFiddle,应该在Firefox和Chrome中查看

.container { height: 20em; display: flex; flex-direction: column; border: 5px solid black } .item { flex: 1; border-bottom: 1px solid white; } .item-inner { height: 100%; width: 100%; display: table; } a { background: orange; display: table-cell; vertical-align: middle; } <div class="container"> <div class="item"> <div class="item-inner"> <a>Button</a> </div> </div> <div class="item"> <div class="item-inner"> <a>Button</a> </div> </div> <div class="item"> <div class="item-inner"> <a>Button</a> </div> </div> </div>

我用Angular -cli生成了Angular 2.0.0应用。

当我创建一个组件并将其添加到AppModule的declarations数组时,一切都很好,它可以工作。

我决定分离组件,所以我创建了一个TaskModule和一个组件TaskCard。现在我想在AppModule的一个组件(Board组件)中使用TaskCard。

AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';
import { BoardComponent } from './board/board.component';
import { LoginComponent } from './login/login.component';

import { MdButtonModule } from '@angular2-material/button';
import { MdInputModule } from '@angular2-material/input';
import { MdToolbarModule } from '@angular2-material/toolbar';

import { routing, appRoutingProviders} from './app.routing';
import { PageNotFoundComponent } from './page-not-found/page-not-found.component';

import { UserService  } from './services/user/user.service';
import { TaskModule } from './task/task.module';


@NgModule({
  declarations: [
    AppComponent,
    BoardComponent,// I want to use TaskCard in this component
    LoginComponent,
    PageNotFoundComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    MdButtonModule,
    MdInputModule,
    MdToolbarModule,
    routing,
    TaskModule // TaskCard is in this module
  ],
  providers: [UserService],
  bootstrap: [AppComponent]
})
export class AppModule { }

TaskModule:

import { NgModule } from '@angular/core';
import { TaskCardComponent } from './task-card/task-card.component';

import { MdCardModule } from '@angular2-material/card';

@NgModule({
  declarations: [TaskCardComponent],
  imports: [MdCardModule],
  providers: []
})
export class TaskModule{}

整个项目可以在https://github.com/evgdim/angular2上找到(看板文件夹)

我错过了什么?我要在BoardComponent中使用TaskCardComponent需要做什么?

我目前正在尝试将一个基于solr的应用程序迁移到elasticsearch。

我有这个lucene查询:

(( 
    name:(+foo +bar) 
    OR info:(+foo +bar) 
)) AND state:(1) AND (has_image:(0) OR has_image:(1)^100)

据我所知,这是一个must子句与布尔OR的组合:

获取所有包含(foo AND bar in name)或(foo AND bar in info)的文档。之后,根据条件state=1过滤结果,并增强具有图像的文档。

我一直试图使用bool查询必须,但我未能得到布尔或必须子句。以下是我所拥有的:

GET /test/object/_search
{
  "from": 0,
  "size": 20,
  "sort": {
    "_score": "desc"
  },
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "name": "foo"
          }
        },
        {
          "match": {
            "name": "bar"
          }
        }
      ],
      "must_not": [],
      "should": [
        {
          "match": {
            "has_image": {
              "query": 1,
              "boost": 100
            }
          }
        }
      ]
    }
  }
}

如你所见,info的must条件缺失了。

**更新**

我已经更新了我的elasticsearch查询,并摆脱了该函数得分。我的基本问题仍然存在。