以角度2安装模块

时间:2017-06-21 17:03:33

标签: angular

我想在我的angular 2应用程序中运行ngx-date-picker。 https://www.npmjs.com/package/ngx-date-picker

安装说明看起来很稀疏,并且演示不存在,所以我正以蜗牛的速度戳它。

我们正在使用纱线,所以我在node_modules下面的文件夹上运行了 yarn add ngx-date-picker --save ,现在我有一个/ ngx-date -picker /文件夹在那里。

我已经进入 package.json 并添加了该组件,但我真的不知道我的语法是否合适:

from django.contrib.humanize.templatetags.humanize import ordinal
var = ordinal(number)

现在我已经进入了 app.module.ts 并完成了导入,就像在自述文件中所说:

#main-sidebar-container {
  padding:15px;
  /*overflow:hidden;*/
  width:300;
  position: absolute;
  z-index: 1111111;
}

.primary-content {
  position: absolute;
  z-index: 0;
}

然后

{
  "name": "arv2",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "build-prod": "set NODE_ENV=production && webpack",
    "watch-build": "webpack --progress --colors --watch",
    "lint": "ng lint",
    "i18n": "ng-xi18n --i18nFormat=xlf",
    "publish-prod": "yarn run build-prod && yarn run publish",
    "publish": "dotnet publish -o \"..\\Publish\\leaves\"",
    "build": "webpack",
    "start": "webpack-dev-server --port=4200",
    "test": "karma start ./karma.conf.js",
    "prepree2e": "npm start",
    "pree2e": "webdriver-manager update --standalone false --gecko false --quiet",
    "e2e": "protractor ./protractor.conf.js"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "@ngx-translate/core": "^7.0.0",
    "@ngx-translate/http-loader": "^0.1.0",
    "ngx-date-picker": "^0.0.0",
    "angular2-jwt": "^0.2.3",
    "core-js": "^2.4.1",
    "ngx-bootstrap": "^1.7.1",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },

不幸的是,Visual Studio告诉我无法找到模块'ngx-date-picker'

它也找不到 '。/ ngx-date-picker''ngx-date-picker / ngx-date-picker''ngx-date-picker / ngx- date-picker.js'或任何其他组合。

不确定接下来要尝试什么。

1 个答案:

答案 0 :(得分:0)

在网站上详细安装,但请检查以下步骤:

1.step:  yarn add ngx-date-picker --save-dev

然后检查已安装的bootstrap,因为此模块需要bootstrap 3或4。

<!-- index.html -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

<!--- index.html -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet">

如果您使用bootstrap 4和普通CSS,请将样式文件检查为

"styles": [  
   "../node_modules/bootstrap/dist/css/bootstrap.min.css",  
   "styles.css"  
   ],

我认为通过导入

就足够了
 import {DatepickerModule} from 'ngx-date-picker';