Let's dive in... I am dealing with a controller
$scope.selectedScript = {};
$scope.selectedScript.scriptId = null;
$scope.selectScript = function(script, index) {
$scope.selectedScript = script;
$scope.selectedRow = index;
myAppFactory.updateTextArea(script).success(
function(data) {
$scope.selectedScript = data;
});
};
$scope.getSelectedClass = function(script) {
if ($scope.selectedScript.scriptId != undefined) {
if ($scope.selectedScript.scriptId == script.scriptId) {
return "selected";
}
}
return "";
};
I have crafted an html page
<label>Script ID:</label>
<input name="scriptId"
type="text"
id="scriptId"
ng-model="selectedScript.scriptId"
ng-disabled="true"
value="{{selectedScript.scriptId}}" />
thanks to IARKI, I now have this
<script type="text/javascript">
function goTo (){
var param1 = angular.element(document.querySelector('.scriptId')).scope.selectedScript.scriptId;
location.href=this.href + '?scriptId='+param1;
return false;
}
</script>
<a href="http://localhost:8080/DSS-war/debug.html" target="_blank" onclick="goTo()">Debug</a>
I also have a list of scripts in a table
<table class="scripts" name="tableScript" arrow-selector>
<tr bgcolor="lightgrey">
<th>Script ID</th>
<th>File Name</th>
</tr>
<tr
ng-repeat="s in scripts | filter:searchField | orderBy:'scriptId'"
ng-click="selectScript(s, $index)" ng-class="getSelectedClass(s)">
<td>{{s.scriptId }}</td>
<td>{{s.fileName }}</td>
</tr>
</table>
Upon clicking the above link, a new tab opens, but the link remains as
http://localhost:8080/DSS-war/debug.html
However, I want it to open in a new tab and look like this:
http://localhost:8080/DSS-war/debug.html?scriptId=1
http://localhost:8080/DSS-war/debug.html?scriptId=2
http://localhost:8080/DSS-war/debug.html?scriptId=12
and so forth... with different numbers
any suggestions?
It needs to be with the onclick function, not the ng-click I know how it functions with ng-click, but I need to make it work with onclick...
and now, I am encountering this error from the chrome debugger:
Uncaught TypeError: Cannot read property 'scriptId' of undefined
at this line
var param1 = angular.element(document.querySelector('.scriptId')).scope.selectedScript.scriptId;