The value for the "data" is getting updated after response is resolved from your getData() service. I am assuming you are hitting a service and getting the data. Nevertheless, the promise would be resolved once the service returns the response. The View meanwhile tries to render the template and as it evaluates the expression data[0], its doesn't find any element at 0 as the data has not still arrived from the service. Hence you get the error as the element at 0th index is undefined.
You should be using an observable here.