0
Hello I’m new in Angularjs, I appreciate any help if you can. I have a question: I have a collection of items that are loaded on the main page is all ok ,but one of the items is a url and I would like when loaded allow you to access the landing page. In reality when I put the url directly into the function it works, but trying to take from a variable ,I click and nothing happens .. the code below works *** .
var data = {};
var app = angular.module('myApp',['onsen']);
module.controller('myCtrl',function($window, $scope){
$scope.myFunction = function(){
$window.location.href = ' **colocando o caminho de uma pagina aqui funciona, mas quero pegar da variavel myurl abaixo.**'
}
});
Almost complete code below.. JS and html ..
module.factory('$data', function() {
data.items = [
{
Image: 'steak-353115_640.jpg',
title: 'Novo',
label: 'Evento',
desc: 'Gerencie um novo evento e .....,
myurl: 'home.html'
},
{ Image: 'r878.jpg',
title: 'Lista',
label: 'Assistente',
desc: 'Não definido',
myurl: 'guia.html'
}
];
return data;
});
var data = {};
var app = angular.module('myApp',['onsen']);
module.controller('myCtrl',function($window, $scope){
$scope.myFunction = function(){
$window.location.href = myurl //Eu queria pegar a url da variável
}
});
As I click on an item it loads the respective values of the variables, ie ,nuncarepete since the data are unique
<ons-list modifier="inset" style="margin-top: 10px">
<ons-list-item class="item">
<ons-row>
<ons-col width="60px">
<div ><img class="item-thum" ng-src="images/{{item.Image}}" style="margin:auto;"></div>
</ons-col>
<ons-col>
<header>
<span class="item-title">{{item.title}}</span>
<span class="item-label">{{item.label}}</span>
</header>
<p class="item-desc">{{item.desc}}</p>
</ons-col>
</ons-row>
</ons-list-item>
<div ng-controller="myCtrl">
<ons-list-item modifier="chevron" ng-click="myFunction()">
<ons-icon icon="ion-chatboxes" fixed-width="true" style="color: #ccc"></ons-icon>
Add a note
</ons-list-item>
Can print the values that are being filled in the url?
– Emir Marques
if I do : '{{item.myurl}}' load the data ,but can’t navigate, I don’t even know how to do it.
– Leogreen
Pass it by parameter:
myFunction(item.myurl)
. Modify your method to use the URL passed by parameter.– Vinícius Gobbo A. de Oliveira
I tried it ,but nothing <ons-list-item Modifier="chevron" ng-click= "myFunction(item.myurl)">
– Leogreen
What would be the ons-list and ons-list-item?
– Emir Marques
Onsen ui ( framework)
– Leogreen
follow the files if anyone can give me a hint, in addition to the ones I’ve already received (thank you) https://dl.dropboxusercontent.com/u/103204235/test%20angularj.rar
– Leogreen