Jump to content

if i'm messing about creating myself a website, just a simple blog however I am trying to create edit links that only show when an admin is logged in and then open up the edit page in a pop up however I am having some problems.

the problem is that the ID of the post if gotten from AngularJS

echo "{{x.ID}}"; //echos the ID
echo "<a href='includes/edit.php?ID={{x.ID}}'>Edit</a>"; //echos the ID
echo "<a href='' onclick='popUp(\"includes/edit.php?ID={{x.ID}}\")'>Edit</a>"; // echos {{x.ID}} and not the ID

My popup function works fine when writing out the HTML is I know the problem is there PHP. This one is really bugging me. 

 

Here is a screen shot as you can the link sends the ID of 10 but the pop give {{x.ID}}

 

 

Screenshot from 2016-06-10 15-52-24.png

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
https://linustechtips.com/topic/609099-angularjs-php/
Share on other sites

Link to post
Share on other sites

Well, that code echoed by PHP would have to be inside Angular template to actually render, but still for a clean code you should make an API for Angular to retrieve "is admin" bool flag and decide to show or not the admin link. And as it's a single-page-application PHP changes won't happen for any route changes that will happen when you click through Angular applications.

Link to comment
https://linustechtips.com/topic/609099-angularjs-php/#findComment-7893618
Share on other sites

Link to post
Share on other sites

12 hours ago, riklaunim said:

Well, that code echoed by PHP would have to be inside Angular template to actually render, but still for a clean code you should make an API for Angular to retrieve "is admin" bool flag and decide to show or not the admin link. And as it's a single-page-application PHP changes won't happen for any route changes that will happen when you click through Angular applications.

I'm only new to angular so i'm only using it to display the posts. I actually fixed this error but only passing the ID to the function and adding it to the end of the URL. I now have a new issue where on my computer the ng-repeat works fine but when uploaded to a web server i get ng-repeat dupes. The wonders of web development :/

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
https://linustechtips.com/topic/609099-angularjs-php/#findComment-7895934
Share on other sites

Link to post
Share on other sites

48 minutes ago, riklaunim said:

SPA frameworks tend to have high entry level. I'm developing in Ember and sometimes problems arise that aren't easily solvable and need some time of few developers ;)

 

I actually gave up on making the pop up and just used a link to a new page. Might go back to the problem one day.

 

AngularJS is pretty nice but im a a very basic level.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
https://linustechtips.com/topic/609099-angularjs-php/#findComment-7904066
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×