Ionic equivalent code of a javascript?

What is the eqivalent ionic/angular code for the following JS code -

Angular Controller Code -

var testid = document.querySelector('#testid') || [];
if(testid.length == 0)
    testid.dataset = {};
var maxdateval = testid.dataset.maxdateval || -1000;
var mindateval = testid.dataset.mindateval || -90000;

Template Code -

<input type="date" name="field1" ng-model="answer" data-maxdateval="{{maxrange}}" data-mindateval="{{minrange}}" id="testid" >

Though its working in browsers, but I doubt it would work in mobile, let me know how I can achieve the desire output.