yabab-dev/ng2-codemirror

LineNumbers do not show up in CodeMirror editor

opensso opened this issue · 4 comments

Hello,

Could please help me with the issue I have with CodeMirror. I'm using it with Angular 4 application. I try to make LineNumbers work. Syntax highlight seems to work just fine. But lineNumbers do not appear. See attached screenshot. Console doesn't show any errors.
2017-07-13_2213

I've imported the following into package.json:

"codemirror": "^5.27.4",
"ng2-codemirror": "^1.1.3",

.angular-cli.json:

      "styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "../node_modules/font-awesome/css/font-awesome.min.css",
        "../node_modules/codemirror/lib/codemirror.css",
        "styles.css"
      ],
      "scripts": [],

app.module.ts

import {CodemirrorModule} from "ng2-codemirror";

@NgModule({
  imports: [
    ...
    CodemirrorModule,
    ...
  ],
  declarations: [ EditorComponent]
})
export class InterviewModule { }

editor.component.ts

import 'codemirror'
import 'codemirror/mode/javascript/javascript'

@Component({
  selector: 'app-editor',
  templateUrl: './editor.component.html',
  styleUrls: ['./editor.component.css'],
  providers: [ MessageService ]
})
export class EditorComponent implements OnInit {

  content: string = '';

  codeMirrorConfig: {
    lineNumbers: true,
    lineWrapping: true,
    mode: 'javascript'
  };
}

editor.component.html

<codemirror [(ngModel)]="content"
  [config]="codeMirrorConfig">
</codemirror>

Self-resolved.

@opensso How did you resolve this?

@Derekjohnson277 I was re-importing CodeMirror as a part of some other activity and it started working. I don't have exact steps which helped, sorry.

@opensso alright sounds good, thanks