对象值内的Html文件内容

时间:2017-10-26 12:29:42

标签: angular ionic-framework

您能告诉我如何将HTML文件作为我的描述内容而不是字符串(如下面的代码所示)引用Angular / Ionic? 我希望:

  1. items[0].description包含来自angular.html的内容
  2. items[1].description包含来自css.html
  3. 的内容

    请帮帮我!提前致谢!

    export class BasicPage {
    
     items = [];
    
     constructor(public nav: NavController) {
       this.items = [
        {
        'title': 'Angular',
        'icon': 'angular',
        'description': 'A powerful Javascript framework for building single page apps. Angular is open source, and maintained by Google.',
        'color': '#E63135'
        },
        {
        'title': 'CSS3',
        'icon': 'css3',
        'description': 'The latest version of cascading stylesheets - the styling language of the web!',
        'color': '#0CA9EA'
        }
      ];
     }
    }
    

1 个答案:

答案 0 :(得分:0)

我建议创建一个单独的函数(例如getHTMLFile())来返回html内容。要获取html内容,请对您的html文件进行http调用

<a href="/<%= @tasksname.downcase %>/new?student_id=<%= student_id=element.id %>&task_id=<%= assessment.task.id %> ">

并从每个项目的描述中调用此函数,并使用JSON.stringify()对从此函数返回的输出进行字符串化。

http.get("/yout_html_file_path").map((html:string) => this.template = html