Reputation: 5
Can i use angular expression in function to pass certain value?
Question can i use regular javascript function or i must use only functions that i specified in My OptionControler?
my HTML HEAD
<script>
function tvarURL(value){console.log(value)}
</script>
my HTML
<div ng-controller="OptionControler" >
<ul>
<li ng-repeat="grupe in grupes" ng-click="tvarURL(grupe.grupe)">
{{grupe.grupe}}
</li>
</ul>
</div>
My OptionControler with JSON FILE This is smaler version of json file
var module = angular.module('app', ['onsen']);
module.controller('OptionControler', ['$scope',
function rodyti($scope) {
$scope.grupes = [
{
"grupe": "MM4-1",
"URL": "https://spreadsheets.google.com/feeds/list/1BYBxGHSPEGNrV2jvJV_c6gJwRzkHwy0OL4avnk8O9S0/od6/public/values?alt=json",
"fakultetas": "TKF",
"tipas": "nuolatines",
"kursas": "kursas1"
},
{
"grupe": "MM4-2",
"URL": "https://spreadsheets.google.com/feeds/list/1FQmHYUpIt6GYxOKB63Smtk-6LBUiKUyCY_HTniGuR_M/od6/public/values?alt=json",
"fakultetas": "TKF",
"tipas": "Nuolatinės",
"kursas": "kursas1"
}
];
}]);
Upvotes: 0
Views: 106
Reputation: 1701
Yes you can, but remove the curly brackets.
ng-click="tvarURL(grupe.grupe)"
Upvotes: 0
Reputation: 104775
You just need to omit the {{}}
<li ng-repeat="grupe in grupes" ng-click="tvarURL(grupe.grupe)">
Upvotes: 2