Angular ui router plus PHP

2

Currently I have an array in php that converts to JSON using json_encode json and generated without problems.

$array = array('a' => 'Olá mundo', 'b' => 'Olá Marte');
$array = json_encode(array);
//$array agora retorna {"a":"Olá mundo","b":"Olá Marte"} .

I'm using angular ui router to dynamically change my pages, usually when you want to send parameters by wm -router we use

<a href="#" ui-sref="ver({parametro:valor})"> clique aqui </a>

It works normally, and can valor without a json object made javascript.

Now how much do I try to do?

<a href="#" ui-sref="ver({parametro:"<?php echo json_encode($array) ?>"})"> clique aqui </a>

The console returns me the following error

Error: Invalid state ref 'view({video:{'
D@http://localhost/arte/js/angular-ui-router/release/angular-ui-router.min.js:7:25266
I/<.link@http://localhost/arte/js/angular-ui-router/release/angular-ui-router.min.js:7:26135
ab/<@http://localhost/arte/js/angular/angular.min.js:16:69
ta@http://localhost/arte/js/angular/angular.min.js:84:35
n@http://localhost/arte/js/angular/angular.min.js:69:226
g@http://localhost/arte/js/angular/angular.min.js:60:496
g@http://localhost/arte/js/angular/angular.min.js:61:12
g@http://localhost/arte/js/angular/angular.min.js:61:12
g@http://localhost/arte/js/angular/angular.min.js:61:12
ba/<@http://localhost/arte/js/angular/angular.min.js:60:119
B/<.compile/<@http://localhost/arte/js/angular-ui-router/release/angular-ui-router.min.js:7:24965
ab/<@http://localhost/arte/js/angular/angular.min.js:16:69
ta@http://localhost/arte/js/angular/angular.min.js:84:35
n@http://localhost/arte/js/angular/angular.min.js:69:226
g@http://localhost/arte/js/angular/angular.min.js:60:496
ba/<@http://localhost/arte/js/angular/angular.min.js:60:119
gc/<@http://localhost/arte/js/angular/angular.min.js:65:279
l@http://localhost/arte/js/angular-ui-router/release/angular-ui-router.min.js:7:23877
A/l.compile/</<@http://localhost/arte/js/angular-ui-router/release/angular-ui-router.min.js:7:24297
If/this.$get</m.prototype.$broadcast@http://localhost/arte/js/angular/angular.min.js:150:426
w/z.transitionTo/z.transition<@http://localhost/arte/js/angular-ui-router/release/angular-ui-router.min.js:7:19286
h/<@http://localhost/arte/js/angular/angular.min.js:134:167
If/this.$get</m.prototype.$eval@http://localhost/arte/js/angular/angular.min.js:148:43
If/this.$get</m.prototype.$digest@http://localhost/arte/js/angular/angular.min.js:145:83
If/this.$get</m.prototype.$apply@http://localhost/arte/js/angular/angular.min.js:148:339
l@http://localhost/arte/js/angular/angular.min.js:101:87
sg/</t.onload@http://localhost/arte/js/angular/angular.min.js:106:489
 <a href="#" ui-sref="view({video:{"           titulo":"a","urlvideo":"htt","duracao":"2:2","datapub":"2017-02-15","views":"100","descricao":"white","palavraschave":"ley"}})"="">
    
asked by anonymous 15.02.2017 / 13:44

1 answer

1

You have a couple of double quotes, try without them:

<a href="#" ui-sref="ver({parametro:<?php echo json_encode($array) ?>})"> clique aqui </a>

Dare they be needed, use single quotation marks:

<a href="#" ui-sref="ver({parametro:'<?php echo json_encode($array) ?>'})"> clique aqui </a>
    
15.02.2017 / 13:56