小编Ale*_*ler的帖子

无法获得角度材料md-sidenav为100%高度

我正在使用带有sidenav的angular2-material制作一个新的angular2应用程序.我不能为我的生活得到那个高度为100%的sidenav.我正试图让一个菜单滑出来占据屏幕的整个高度.无论用户在哪里滚动,我都希望它以相同的方式打开.

这是我的模板:

<md-sidenav-layout class="demo-sidenav-layout">
  <md-sidenav #start mode="over">

    <a [routerLink]="['/login']" class="btn btn-primary">Log in</a>
    <br>
  </md-sidenav>
    <md-toolbar color="primary">

      <button md-button (click)="start.toggle()">Open Side Drawer</button>
      <span>Spellbook</span>

      <span class="demo-fill-remaining">

      </span>

    </md-toolbar>
  <div class="demo-sidenav-content">

    <router-outlet></router-outlet>
  </div>
</md-sidenav-layout>
Run Code Online (Sandbox Code Playgroud)

这是我的CSS:

.demo-sidenav-layout {
  //border: 3px solid black;
  min-height:100%;
  md-sidenav {
    padding: 10px;
    background: gainsboro;
    min-height: 100%;
  }
}

.demo-sidenav-content {
  padding: 15px;
  min-height:100%;
}

.demo-toolbar {
  padding: 6px;

  .demo-toolbar-icon {
    padding: 0 14px 0 14px;
  }

  .demo-fill-remaining {
    flex: 1 1 auto;
  }

}
Run Code Online (Sandbox Code Playgroud)

我也html设置height:100%并 …

css angular-material angular

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

如何以编程方式关闭ng-bootstrap模式?

我有一个模态:

<template #warningModal let-c="close" let-d="dismiss">
  <div class="modal-header">
    <button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
      <span aria-hidden="true">&times;</span>
    </button>
    <h4 class="modal-title">Warning</h4>
  </div>
  <div class="modal-body">
      The numbers you have entered result in negative expenses.  We will treat this as $0.00.  Do you want to continue?
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-secondary" (click)="c('Close click')">No</button>
    <button type="button" class="btn btn-secondary" (click)="submit()">Yes</button>
  </div>
</template>
Run Code Online (Sandbox Code Playgroud)

每当我单击是,我希望它调用一个函数并关闭它自己.
在我的控制器@ViewChild('warningModal') warning;submit(),我有this.warning.close();,而且我有,但this.warning.close is not a function每当我点击是时我都会得到.

我如何让它以我想要的方式工作?

ng-bootstrap angular

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

如何获取缩小的javascript堆栈跟踪并针对源映射运行它以获取正确的错误?

在我们的生产服务器上,我已经缩小了javascript的发布,并且我没有包含它的地图文件,因为我不希望用户能够根据错误了解发生了什么.

我有一个日志服务我写的是通过电子邮件将角度异常(由$ exceptionHandler捕获)转发给自己.但是,此堆栈跟踪几乎不可读:

n is not defined
    at o (http://localhost:9000/build/app.min.js:1:3284)
    at new NameController (http://localhost:9000/build/app.min.js:1:3412)
    at e (http://localhost:9000/build/bower.min.js:44:193)
    at Object.g.instantiate (http://localhost:9000/build/bower.min.js:44:310)
    at b.$get (http://localhost:9000/build/bower.min.js:85:313)
    at d.compile (http://localhost:9000/build/bower.min.js:321:23333)
    at aa (http://localhost:9000/build/bower.min.js:78:90)
    at K (http://localhost:9000/build/bower.min.js:67:39)
    at g (http://localhost:9000/build/bower.min.js:59:410)
    at http://localhost:9000/build/bower.min.js:58:480 <ui-view class="ng-scope">
Run Code Online (Sandbox Code Playgroud)

我想知道的是:是否有一个程序,我可以通过地图文件(或不通过地图文件,如果有另一种方式)分析这个堆栈跟踪与实际的非缩小源代码

javascript minify angularjs

27
推荐指数
4
解决办法
4771
查看次数

Post FromBody始终无效

我有一个新的API,我正在使用ASP.NET Core构建,我无法将任何数据POST到端点.

这是端点的样子:

[HttpPost]
[Route("StudentResults")]
public async Task<IActionResult> GetStudentResults([FromBody]List<string> userSocs, [FromBody]int collegeId)
{
    var college = await _collegeService.GetCollegeByID(collegeId);
    // var occupations = await _laborMarketService.GetOccupationProgramsBySocsAndCollege(userSocs, college);
    return Ok();
}
Run Code Online (Sandbox Code Playgroud)

这就是我通过Postman发送的有效载荷如下所示:

{
    "userSocs": [
            "291123",
            "291171",
            "312021",
            "291071",
            "152031",
            "533011"
        ],
    "collegeId": 1
}
Run Code Online (Sandbox Code Playgroud)

我确保我将postman设置为POST,用Content-Type application/json.我究竟做错了什么?

c# http-post asp.net-core

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

tsc不排除node_modules

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试将angular2/beta8应用程序升级到RC1,而我正在根据Quickstart指南进行基本重组.

我将其tsconfig.json复制到我的项目目录中.我想我已准备好其他一切,但是当我运行时tsc,我在node_modules文件夹中的文件中会遇到各种错误.为什么它首先在那里寻找?

typescript tsc angular

15
推荐指数
2
解决办法
6600
查看次数

Angular2延迟加载服务被实例化两次

我今天刚刚将我的应用程序切换为延迟加载.
我有一个SharedModule导出一堆服务.在我AppModule,我导入SharedModule因为AppComponent需要访问一些共享服务.

在另一个模块中FinalReturnModule,我导入SharedModule.在我的一个服务中,我console.log('hi')在构造函数中添加了一个.

当应用程序首次加载时,我会hi进入控制台.每当我导航到我内心的页面时,FinalReturnModule我会hi再次进入.显然,由于有两个实例,因为模块无法通信,所以没有任何工作正常.

如何阻止服务实例化两次?

编辑:背景,该应用程序使用angular-cli构建.

当前版本:

angular-cli: 1.0.0-beta.24
node: 6.9.1
os: win32 ia32
@angular/common: 2.4.1
@angular/compiler: 2.4.1
@angular/core: 2.4.1
@angular/forms: 2.4.1
@angular/http: 2.4.1
@angular/platform-browser: 2.4.1
@angular/platform-browser-dynamic: 2.4.1
@angular/router: 3.1.1
@angular/compiler-cli: 2.4.1
Run Code Online (Sandbox Code Playgroud)

angular2-routing angular2-services angular2-modules angular

10
推荐指数
1
解决办法
3117
查看次数

.NET Core Httpclient 有效,但 .Net Framework 4.7.2 httpclient 无效

对不起,标题太糟糕了,我不太确定如何用简短的标题格式来表达我的问题。

我正在尝试与外部 API 通信。我向该 API 发出基本身份验证请求,并从该 API 获取 x-csrf-token 和会话令牌。

然后我向该 API 发出另一个请求,现在使用 x-csrf-token 作为标头,并将会话令牌作为“cookie”附加到标头。

维护 API 的团队给我发送了一个处理上述所有内容的示例项目,它看起来像这样:

public static async Task<string> Send(string apiname, string value)
{
    // Fetch the authorization tokens from SAP
    HttpClient client = new HttpClient();
    client.BaseAddress = new Uri(basePath);
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(user + ":" + password)));
    client.DefaultRequestHeaders.Add("x-csrf-token", "Fetch");
    string csrfToken = "";
    string sessionCookie = "";
    HttpResponseMessage response = await client.GetAsync(string.Empty);
    IEnumerable<string> values;
    if (response.Headers.TryGetValues("x-csrf-token", out values))
    {
        csrfToken = values.FirstOrDefault();
    }
    if (response.Headers.TryGetValues("set-cookie", …
Run Code Online (Sandbox Code Playgroud)

c# dotnet-httpclient asp.net-core

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

如何知道所有Angular2 HTTP调用何时完成

我正在编写一个应用程序,它将监视不同服务器上所有应用程序的当前内部版本号.这是通过在每个应用程序中对txt文件发出http请求来完成的.我正在使用foreach循环.

我遇到的问题是我不确定(使用Observables)如何知道所有请求何时完成.

当请求返回时,我将响应添加为对象数组的属性.然后,一旦我拥有了所有数据,我就将其绑定到组件的模板,然后由管道进行过滤.因此,我需要确保在所有数据完成后才绑定它.

以下是我获取数据的方式:

this.apps.forEach(app => {
  app.Environments.forEach(env => {
    this._buildMonitorService.getBuilds(env.URL)
      .subscribe((data) => {     
        setupBuilds(this.apps,data.url,data._body);
      });                
  });
});
Run Code Online (Sandbox Code Playgroud)

setupBuilds 将响应添加到我的应用程序数组中.

我正在寻找的东西实际上是Promise.all我将绑定 this.builds到数据设置的地方,setupBuilds但我不知道如何使用rxjs observables

rxjs angular

7
推荐指数
1
解决办法
5217
查看次数

如何通过$ stateParams传递对象?

我有一个具有大量状态的ui-router应用程序,我需要能够通过$ stateParams传递模型.在每个$ http请求中,我检查响应是否为"STATE"参数,该参数从服务器返回.如果它存在,我执行$state.go(STATE).

如此有效,我得到了我的$stateProvider:

$stateProvider
    .state('Account', {url: '/Account', template: '<ui-view/>'})
    .state('Account.name', {
        url: '/Name',
        templateUrl: 'app/Account/partials/Name.html',
        controller: 'AccountNameController as nameVm'
    })
Run Code Online (Sandbox Code Playgroud)

还有更多看起来像这样的州.

我有一个数据模型,它只是一个工厂,其对象是通过函数获取和设置的.因此,每当我调用saveAccount()时,它都会获取模型并将其发送到Web API后端.后端验证数据,并用状态参数发送回(或者account.invalid,account.validaccount.needsMoreInfo).这是我的$ httpInterceptor

.factory('httpInterceptor', ['$q', '$injector',
        function ($q,$injector) {
            return {
                'response': function(response) {
                    if(response.data.state){
                        $injector.get('$state').go(response.data.state, response.data.account);
                    }
                    return response;
                }
            };
        }
    ])
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我正在尝试通过stateparams发送帐户.

在控制器中,我基本上需要能够说出来 vm.account = $stateParams.account

我的问题是:

如何修改我的$状态,使其都具有命名控制器并获取状态参数并从控制器访问?

我没有通过服务传递数据的原因是因为有多个模型,所以我不能只在$ httpInterceptor中提供服务的名称,因为它不是常量.

编辑:想出来

这是我的控制器需要的内容:if($ stateParams && $ stateParams.data){vm.Account = $ stateParams.data; }

而这就是州最终看起来像:

.state('taxAccount.invalid', {
            url: '/Invalid?params', …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui-router

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

如何在自定义 ModelBinder 中从body获取数据?

我正在 .NET Core 1.1(完整框架)应用程序中创建 IModelBinder 的自定义实现。

我有一个ActivityModel具有接口属性的类:

public class ActivityModel
{
    public int Id { get; set; }
    public string Title { get; set; }
    public int Type { get; set; }
    public IActivityContent Content { get; set; }    // marker interface  
    //more unimportant props
}
Run Code Online (Sandbox Code Playgroud)

这个想法是客户端可以发送带有Content属性的对象,该属性可以是许多(当前为 8 个,但可能会增加)不同类之一。

通过这种方式,我们可以在 API 中拥有一个端点(针对每个 CRUD 操作)来处理所有这些不同类型的对象。

我正在实现一个 ModelBinder 来将从客户端发送的对象变成一个具体的类,这是我到目前为止所得到的:

    public Task BindModelAsync(ModelBindingContext bindingContext)
    {
        if (bindingContext == null)
        {
            throw new ArgumentNullException(nameof(bindingContext));
        }
        var content = bindingContext.ValueProvider.GetValue("content");

        return …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc model-binding asp.net-core

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