小编Mon*_*Kin的帖子

iFrame上的Angular,onLoad函数

我有这个iframe使用基本的JavaScript:

<iframe id="upload_iframe" name="upload_iframe" onLoad="uploadDone();"></iframe>
Run Code Online (Sandbox Code Playgroud)

uploadDone();在加载iframe的内容时触发该方法.

我如何在Angular中做同样的事情?我想在iframe加载时调用控制器上的函数,但ng-onload到目前为止我还没有看到过.

iframe angularjs

46
推荐指数
3
解决办法
6万
查看次数

没有ChildrenOutletContexts的提供者(injectionError)

使用Angular CLI为我的应用程序生成路由模块时出现以下错误:

ERROR Error: No provider for ChildrenOutletContexts!
    at injectionError (core.es5.js:1169)
    at noProviderError (core.es5.js:1207)
    at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._throwOrNull (core.es5.js:2649)
    at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._getByKeyDefault (core.es5.js:2688)
    at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._getByKey (core.es5.js:2620)
    at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_.get (core.es5.js:2489)
    at resolveNgModuleDep (core.es5.js:9481)
    at NgModuleRef_.webpackJsonp.../../../core/@angular/core.es5.js.NgModuleRef_.get (core.es5.js:10569)
    at resolveDep (core.es5.js:11072)
    at createClass (core.es5.js:10936)
Run Code Online (Sandbox Code Playgroud)

我使用Angular CLI生成了路由模块,如下所示:

ng generate module --routing App
Run Code Online (Sandbox Code Playgroud)

这是路由模块的内容:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { MyComponent } from './my/my.component';

const routes: Routes = [
  {
    path: '',
    component: MyComponent,
  },
];

@NgModule({
  imports: [RouterModule.forChild(routes)], …
Run Code Online (Sandbox Code Playgroud)

angular

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

Angular2版本RC.6"指令"在@Component错误中

我正在使用Angular2并从官方网站下载了package.json.当我试图在@Component装饰器中使用"指令"时,我收到此错误.

我附上了我的代码错误:

[ts]
Argument of type '{ selector: string; template: string; directives: string; 
}' is not assignable to parameter of type 'ComponentMetadataType'.

Object literal may only specific known properties, and 'directives' does not
exist in type 'ComponentMetadataType'.
(property) directives: string
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

import { Component } from '@angular/core';
import { PeopleListComponent } from './people-list/people-list.component';

@Component({
 selector: 'my-app',
 template: '<h1>{{ title }}</h1>',
 directives: ''   //ERROR //NOT ABLE TO RECOGNIZE
})

export class AppComponent { 
  title = "My title";
} 
Run Code Online (Sandbox Code Playgroud)

这是我的package.json:

        {
          "name": …
Run Code Online (Sandbox Code Playgroud)

angularjs-directive angular2-template angular

21
推荐指数
2
解决办法
3万
查看次数

指定要与gcloud sql连接的数据库

连接到Google Cloud SQL实例时,有没有办法指定要连接的数据库?

这是我执行的命令和我得到的错误:

$ gcloud beta sql connect MY_INSTANCE --user=MY_USER
Whitelisting your IP for incoming connection for 5 minutes...done.
Connecting to database with SQL user [MY_USER].Password for user MY_USER:
psql: FATAL:  database "MY_USER" does not exist
Run Code Online (Sandbox Code Playgroud)

它似乎尝试连接到一个与用户名称相同的数据库,但是当不是这样的时候呢?(我不想创建一个名为MY_USER的虚拟DB,只是为了能够跳转到我想要的DB).

以下是该命令的文档gcloud beta sql,但我认为没有任何有用的内容:https://cloud.google.com/sdk/gcloud/reference/beta/sql/connect

google-cloud-sql

21
推荐指数
2
解决办法
3989
查看次数

在CLion中设置构建目标

我正在尝试设置CLion(Windows 8.1,64位,使用cygwin而不是mingw),我正在尝试编译+运行项目,但我不知道该怎么做:

在此输入图像描述

它说我需要一个目标和一个配置,但下拉列表中没有.我错过了配置步骤吗?

c++ clion

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

如何更改包括目录,图书馆目录和CLION图书馆

在CLion中,如何指定C++编译器将查找头文件的include目录?另外,如何设置要链接的库及其库目录?

目前我正在执行直接修改文件的任务CMakeLists.txt:

include_directories(/opt/netcdf/include)
link_directories(/opt/netcdf/lib)
link_libraries(netcdf)
Run Code Online (Sandbox Code Playgroud)

但我想知道是否有可能使用GUI完成相同的事情.

谢谢

clion

13
推荐指数
1
解决办法
1万
查看次数

什么是开始...结束于Erlang用于?

我只是begin...end在Erlang的文档(这里)中踩了一脚,但它没有给出一些如何有用的例子.

在StackOverflow中查看我发现了两个人们将要使用的情况begin...end,两者都在列表推导中:

但我想知道是否有更多此类用途.

任何人都可以提供另一种方案,其中a begin...end在Erlang中有用吗?

谢谢

erlang expression block

12
推荐指数
3
解决办法
2714
查看次数

JDK的try-with-resources示例中的不良做法?

我在Java 的try-with-resources文档中找到了这个例子:

static String readFirstLineFromFile(String path) throws IOException {
    try (BufferedReader br = new BufferedReader(new FileReader(path))) {
        return br.readLine();
    }
}
Run Code Online (Sandbox Code Playgroud)

如果构造函数BufferedReader抛出异常,则FileReader不会释放由其持有的资源.所以这不是一个不好的做法,而不是:

static String readFirstLineFromFile(String path) throws IOException {
    try (FileReader fr = new FileReader(path);
         BufferedReader br = new BufferedReader(fr)) {
        return br.readLine();
    }
}
Run Code Online (Sandbox Code Playgroud)

java try-with-resources

9
推荐指数
1
解决办法
286
查看次数

Python的argparse:如何使用关键字作为参数的名称

lambda 在Python中有一个关键字函数:

f = lambda x: x**2 + 2*x - 5
Run Code Online (Sandbox Code Playgroud)

如果我想将它用作变量名称怎么办?有逃脱序列还是其他方式?

你可能会问为什么我不使用其他名字.这是因为我想使用argparse:

parser = argparse.ArgumentParser("Calculate something with a quantity commonly called lambda.")
parser.add_argument("-l","--lambda",help="Defines the quantity called lambda", type=float)
args = parser.parse_args()

print args.lambda # syntax error!
Run Code Online (Sandbox Code Playgroud)

使用--help选项调用的脚本给出:

...
optional arguments
  -h, --help            show this help message and exit
  -l LAMBDA, --lambda LAMBDA
                        Defines the quantity called lambda
Run Code Online (Sandbox Code Playgroud)

因此,我想继续lambda作为变量名称.解决方案也可能是argparse相关的.

python lambda argparse

8
推荐指数
1
解决办法
1701
查看次数

使用std :: ostream作为打印函数的参数

我一直习惯cout打印声明,但现在我想学习打印passing the stream,就像 void print(std::ostream&) const;我目前的打印功能一样

template <class T>

void Mystack<T>::print()
{
    for (int i = 0; i <= top; i++)
    {
        std::cout << input[i] << " ";
    }
}
Run Code Online (Sandbox Code Playgroud)

我有两个问题:

  1. 从我上面实现的普通打印功能切换到使用的打印功能有什么好处ostream.
  2. 如何ostream在我的功能中实现.我试图ostream从互联网来源了解但无法理解.请帮忙.

以下是完整的运行代码:

//*************STACK CODE***************//

//VERY GOOD EXAMPLE TO UNDERSTAND RULE OF THREE FOR BEGINEERS http://www.drdobbs.com/c-made-easier-the-rule-of-three/184401400
//RULE OF THREE : Video : https://www.youtube.com/watch?v=F-7Rpt2D-zo
//Thumb Rule : Whenever we have class which has members pointing to heap space we …
Run Code Online (Sandbox Code Playgroud)

c++ iostream ostream

8
推荐指数
1
解决办法
1万
查看次数