2016-10-05 3 views
0

Я хочу использовать MathML внутри Ionic2, я добавил MathJax CDN в index.html, и добавил CUSTOM_ELEMENTS_SCHEMA в app.module.tsНевозможно использовать MathML в Ionic2

<script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=MML_CHTML"></script>

в @ NgModule я использую

import { NgModule,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 
import { IonicApp, IonicModule } from 'ionic-angular'; 
import { MyApp } from './app.component'; 
import { HelloIonicPage } from '../pages/hello-ionic/hello-ionic'; 
import { ItemDetailsPage } from '../pages/item-details/item-details'; 
import { ListPage } from '../pages/list/list'; 
import {MathmlComponent} from '../components/mathml-component/mathml-component'; 

@NgModule({ 
    declarations: [ 
    MyApp, 
    HelloIonicPage, 
    ItemDetailsPage, 
    ListPage, 
    MathmlComponent 
    ], 
    imports: [ 
    IonicModule.forRoot(MyApp) 
    ], 
    bootstrap: [IonicApp], 
    entryComponents: [ 
    MyApp, 
    HelloIonicPage, 
    ItemDetailsPage, 
    ListPage 
    ], 
    providers: [], 
    schemas: [CUSTOM_ELEMENTS_SCHEMA] 
}) 
export class AppModule {} 

Мои MathML-component.ts является

import {Component} from "@angular/core"; 

@Component({ 
    selector:'mathml-component', 
    template:` 
    <math> 
    <mstyle displaystyle="true"> 
     <mover> 
     <mrow> 
      <mi>f</mi> 
     </mrow> 
     <mo>&#x2192;</mo> 
     </mover> 
    </mstyle> 
    </math> 
    ` 
}) 

export class MathmlComponent{ 


    constructor(){ 
    console.log('done') 
    } 
} 

Но я получаю ошибку

polyfills.js:3 Unhandled Promise rejection: Template parse errors: 
':math:mi' is not a known element: 
1. If ':math:mi' is an Angular component, then verify that it is part of this module. 
2. If ':math:mi' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. (" 
     <mover> 
     <mrow> 
      [ERROR ->]<mi>f</mi> 
     </mrow> 
     <mo>&#x2192;</mo> 
"): [email protected]:10 
':math:mrow' is not a known element: 

PLZ помощь.

+0

Примечание от будущего: cdn.mathjax.org приближается к концу своего срока службы, проверьте https://www.mathjax.org/cdn-shutting-down/ на советы по миграции. –

ответ

0

Я нашел решение. Вместо использования MathMl я использую Tex/Latex в MAthjax.

Смежные вопросы