小编Cha*_*irs的帖子

在npm上angular-cli和@ angular/cli之间的区别是什么

npm有2个角度cli包:

angular-cli目前为1.0.0-beta.28.3

@ angular/cli,目前为1.0.0-beta.31

这两个软件包有什么区别,哪个是用于新项目的正确软件包?

棱角分明的文档在这里并不是特别清楚.https://cli.angular.io/对npm install -g angular-cli 说,而https://github.com/angular/angular-cli对npm install -g @ angular/cli说

npm angular

12
推荐指数
1
解决办法
4545
查看次数

在 Entity Framework Core 2.1 中为特定环境播种数据

我正在 EF Core 2.1 中使用新的播种数据方式,并且我只想为开发环境播种数据。

最初我尝试过这个:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") != EnvironmentName.Development)
    {
        return;
    }

    modelBuilder.Entity<Customer>().HasData(new Customer { ... });
}
Run Code Online (Sandbox Code Playgroud)

但是,我注意到生成的迁移始终会将客户插入数据库中。

有没有办法根据环境限制数据种子?

c# entity-framework-core asp.net-core

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

在bootstrap 4中为活动导航栏链接加下划线

我正在将一个网站从bootstrap 3升级到4(测试版).我用来强调活动导航栏链接的CSS已不再有效.它不是强调项目的下划线,而是强调页面的整个宽度.如何在bootstrap 4中为活动导航项加下划线?

示例Navbar

Bootstrap 3 css

.navbar-default .navbar-nav > .active:after {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    content: " ";
    border-bottom: 5px solid #5BC0EB;
}
Run Code Online (Sandbox Code Playgroud)

尝试Bootstrap 4 css

.navbar-light .navbar-nav .active::after {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    content: " ";
    border-bottom: 5px solid #5BC0EB;
}
Run Code Online (Sandbox Code Playgroud)

HTML

<nav class="navbar fixed-top navbar-light bg-light navbar-expand-md">
    <div class="container">
        <a class="navbar-brand" href="#">My Website</a>

        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse"
            aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse justify-content-end" id="main-nav-collapse"> …
Run Code Online (Sandbox Code Playgroud)

css twitter-bootstrap bootstrap-4

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

AngularJS'控制器为'和形式.$有效

我想检查一个角度控制器内的表格是否有效.使用$ scope时这似乎很简单,但是我无法使用'controller as'语法.

当我尝试访问表单时.$ valid我收到错误消息"无法读取属性'$ valid'of undefined".

plunkr:http://plnkr.co/edit/w54i1bZVD8UMhxB4L2JX?p = preview

HTML

<div ng-app="demoControllerAs" ng-controller="MainController as main">
  <form name="contactForm" novalidate>
    <p>
      <label>Email</label>
      <input type="email" name="email" ng-model="main.email" required />
    </p>
    <p>
      <label>Message</label>
      <textarea name="message" ng-model="main.message" required></textarea>
    </p>
    <input type="submit" value="submit" ng-click="main.submit()" />
  </form>
</div>
Run Code Online (Sandbox Code Playgroud)

JS

var app = angular.module('demoControllerAs', []);

app.controller('MainController', [function () {
    var main = this;

    main.submit = function () {
        var isValid = main.contactForm.$valid;
        console.log(isValid);
    };
}]);
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-validation

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

angular ui-bootstrap datepicker mindate在输入时未经验证

我有一个带有ui-bootstrap datepicker的表单.我想阻止这个日期过去.

我将指令的min-date设置设置为a new Date(),如下所示.这样可以正确地防止在使用弹出窗口时选择过去的日期,但是我仍然可以输入过去的日期,这样就可以确认.

如何在输入的日期强制执行最小日期验证?

Plunkr:https://plnkr.co/edit/EHO1BG8BspNMvsoKT30l ? p = preview

HTML:

<div class="input-group">
    <input type="text" 
           class="form-control" 
           uib-datepicker-popup="{{format}}" 
           ng-model="dt" 
           is-open="popup1.opened" 
           min-date="minDate" 
           datepicker-options="dateOptions" 
           ng-required="true" 
           close-text="Close"
           alt-input-formats="altInputFormats"
           name="dt"/>
    <span class="input-group-btn">
        <button type="button" class="btn btn-default" ng-click="open1()">
            <i class="glyphicon glyphicon-calendar"></i>
        </button>
    </span>
</div>
Run Code Online (Sandbox Code Playgroud)

JS:

app.controller('MainCtrl', function($scope) {
  $scope.dt = new Date();
  $scope.minDate = new Date();
  $scope.format = "dd/MM/yyyy";
  $scope.altInputFormats = ['d!/M!/yyyy'];
  $scope.dateOptions = {
    formatYear: 'yy',
    startingDay: 1
  };

  $scope.popup1 = {
    opened: false
  };

  $scope.open1 = function() {
    $scope.popup1.opened = …
Run Code Online (Sandbox Code Playgroud)

datepicker angularjs angular-ui-bootstrap

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