Angular 8 挂载 Mergely + ng-alain

官网

  1. mergely
  2. ng-alaint

原文使用组件
Angular 6.1.1 + mergely
参考项目 Angular 6.1 example of mergelyr
克隆地址 https://github.com/wickedest/mergely-angular

所需物品

1.node.js
2.vsCode
3.npm
(这里就不贴如何安装的了)

执行步骤

  1. 克隆代码
git clone --depth=1 https://github.com/ng-alain/ng-alain.git my-project
cd my-project
yarn
npm start
  1. vsCode打开 my-project 在根目录打开文件

    1. tsconfig.app.json
    2. package.json
    3. angular.json
    4. /src/typings.d.ts
    5. /src/app/routes/routes-routing.module.ts
  2. tsconfig.app.json

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": ["node"]    //<---- 更改为 "types": ["jquery "]
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "src/test.ts",
    "src/**/*.spec.ts"
  ]
}

  1. package.json

ctrl+F 搜索 dependencies
在最后增加

"@angular/http": "^6.1.0",
"codemirror": "^5.32.0",
"core-js": "^2.5.4",
"jquery": "^3.2.1",
"mergely": "^4.0.6"

ctrl+F 搜索 devDependencies
在最后增加

"@types/jquery": "^3.3.5"
  1. angular.json

搜索

  "architect": {
    "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {

在option标签下的

        "styles": [
        ......
          "node_modules/codemirror/lib/codemirror.css",
          "node_modules/mergely/lib/mergely.css",
        ],

        "scripts": [
        ......
          "node_modules/jquery/dist/jquery.js",
          "node_modules/codemirror/lib/codemirror.js",
          "node_modules/mergely/lib/mergely.js"
        ]
  1. /src/typings.d.ts
interface JQuery {
    mergely(options?: any) : any;
 }

插入在最后面

  1. /src/app/routes/routes-routing.module.ts
import { BrowserModule } from '@angular/platform-browser';


@NgModule({
  imports: [
  ......,
    BrowserModule,
    ]

创建新的模块

ng g ng-alain:module mergely
ng g ng-alain:list mergelyScreen -m=mergely

mergelyScreen .ts

  ngOnInit() {
    jQuery(document).ready(() => {
      jQuery('#mergely').mergely({
        lhs: setValue => {
          setValue('the quick red fox\njumped over the hairy dog');
        },
        rhs: setValue => {
          setValue('the quick brown fox\njumped over the lazy dog');
        },
      });
    });
  }

mergelyScreen .html

<div>
  <div class="app mergely-full-screen-8">
    <div class=" mergely-resizer">
      <div id="mergely"></div>
    </div>
  </div>
</div>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值