Angular 2 declaring an array of objects

前端 未结 7 2096
-上瘾入骨i
-上瘾入骨i 2020-12-13 08:48

I have the following expression:

public mySentences:Array = [
    {id: 1, text: \'Sentence 1\'},
    {id: 2, text: \'Sentence 2\'},
    {id: 3,         


        
7条回答
  •  悲哀的现实
    2020-12-13 09:21

    public mySentences:Array = [
        {id: 1, text: 'Sentence 1'},
        {id: 2, text: 'Sentence 2'},
        {id: 3, text: 'Sentence 3'},
        {id: 4, text: 'Sentenc4 '},
    ];
    
    OR
    
    public mySentences:Array = [
        {id: 1, text: 'Sentence 1'},
        {id: 2, text: 'Sentence 2'},
        {id: 3, text: 'Sentence 3'},
        {id: 4, text: 'Sentenc4 '},
    ];
    
        

    提交回复
    热议问题