Add from one array to another by click. Angularjs2 : I have a json like:

    "data":
    [{ 
    "max":10,
    "class":"selected"
    "type":"numbers"
    }]

I want to use an angular *NgIf or other loop, which will start from 1 and to 10 (my max value) and display all the numbers inside span like:

    <span>1</span><span>2</span>...<span>10</span>

Than if I click on the span element i want this element to be added in a new empty array. So lets say I have other empty array:

    newarray: Array<number> = []

Will become:

    newarray = [1]
Additionally I want to toggle class when you click on the span element, taken by the json.class property.