As in, do you do an API call on page load, then ng-repeat on the returned JSON object?
Yes.
As in, do you do an API call on page load, then ng-repeat on the returned JSON object?
Yes.
Yes.
Would this logic go into a service or controller?
I'm still an uber noob when it comes to Angular.
/client/items-view/something.html
<ul><li ng-repeat='item in items'>{{item.Title}}</li></ul>
/client/items-view/something.controller.js
$scope.items = $get('/api/items') // ... calls out to api on server
/server/api/items/items.controller.js
$exports.index = function(req,res) { itemsModel.find(... yada yada look into mongo) }
So basically,
and of course you have the itemsModel built in items/items.model.js (using mongoose) and you setup proper routing so that '/api/items/' exists and directs to the correct function in items.controller.js
Read through the structure of the MEANjs boilerplate project here- https://github.com/meanjs/mean It's an example project setup to use MEAN and it pretty much has examples for all of these structural concepts.
angular.module('ThisCtrl', [])
.controller('ThisController', function($scope, $http) {
$scope.postEntry = [];
$http.get('/api/posts').success(function(post) {
$scope.postEntry = post;
})
});
<div class="list-group" ng-repeat="post in postEntry">
<div class="list-group-item">
<div class="row-picture">
<img class="circle" ng-src="{{ post.img }}" alt="icon">
</div>
<div class="row-content">
<h4 class="list-group-item-heading">{{ post.name }}</h4>
<p class="list-group-item-text">{{ post.desc }}</p>
</div>
<hr />
<a href="/contact" class="btn btn-inverse">I want</a>
<div class="list-group-separator"></div>
</div>
</div>
function run($rootScope) {
$rootScope.$on('$routeChangeSuccess', function (){
$rootScope.$broadcast('checkForMessage');
});
}
Speaking of Angular. What is the best way to do the following; I have a controller that grabs a users info (username and number of messages) and puts in the navigation bar, I want to check this on, essentially, every page. What is the best way to go about doing this?
PHP:
I've been struggling with a website lately... The site is super fast when the user isn't logged in but slows down dramatically when SESSIONS start to be used after log in. I started using session_write_close(); immediately when possible but it doesn't seem to help.
SESSIONS are set to files in /tmp.
Anyone have any ideas on how to improve? I use 8 $_SESSION's per user. Would lowing that improve performance?
My friend and I just launched our first website/startup/company/whatever this morning.
It feels good, but it also utterly terrifying.
Just to test, I changed all the sessions to cookies and the issue disappears. I still haven't found a solution.Are you sure that it's SESSIONS that slows your site down?
See:
http://stackoverflow.com/questions/1791843/php-session-slowdown
http://stackoverflow.com/questions/...e-sessions-slow-down-response-time-and-server
http://stackoverflow.com/questions/7835519/does-using-sessions-too-much-slow-down-performance-in-php
All signs point to nope
Good luck!
I'm so terrified even trying to launch it because it might not be "good enough". I have a demo page running and I'm waiting for the day when I fill it up with legit content.
Thanks!
We've only had two users so far. The whole project is being viewed as a learning experience first and foremost for us. I doubt it will be the last venture we create.
You could use another session handler. We use Redis to store our session data.Just to test, I changed all the sessions to cookies and the issue disappears. I still haven't found a solution.
Speaking of Angular. What is the best way to do the following; I have a controller that grabs a users info (username and number of messages) and puts in the navigation bar, I want to check this on, essentially, every page. What is the best way to go about doing this?
Right I got it working with $broadcast:
Code:function run($rootScope) { $rootScope.$on('$routeChangeSuccess', function (){ $rootScope.$broadcast('checkForMessage'); }); }
However because I have an ng-controller for the Navbar and ng-view it gets called twice. Any ideas on how I should get this working properly? Obviously removing the ng-controller or ngview fixes this, but at the moment I need both.
module.controller('navbarController', function($scope){
$scope.$on('$routeChangeSuccess', function (){
//do your retrieval logic here
});
})
I like what google is doing with their web starter kit
https://developers.google.com/web/fundamentals/resources/styleguide/#table
I like what google is doing with their web starter kit
https://developers.google.com/web/fundamentals/resources/styleguide/#table
At my job here the developers run a local sandbox that mimics the live servers, so I can make api calls and dump the results without doing any damage.
I just have to vent, cleaning up after a couple of WP sites have been compromised to use the server to send out 800k+ worth of spam emails in two days has been a real headache.
Basically my first time having to do this and it's been a tough few days.
I believe it was one of the plugins on the sites that allowed them to run the upload and they then uploaded a php file (which will be turned off when I put the site back) to the uploads directory and off they went.
I've seen the access logs of them fishing about through the various plugins then they got a few PHP files uploaded in various places.
The plugin doesn't allow PHP uploads per se, but the file uploader in WP (they need to be able to upload images) allowed the upload of php files to the upload directory, then that file was executed.
I didn't build the site, and it's about three year olds and was basically left on it own (plugins were out of date etc), basically the worst case scenario. :/
But I'm left to tidying it all up because the people who made it are no longer here.
Have an interview at a local creative webdev/marketing firm on Thursday for an internship.
Do any of you with experience have advice on interviewing for this type of position? So far I have my personal website/blog up to date, and I spent a night looking over their site code to get familiar with it and see if there was anything I could improve. (Ended up finding two things and wrote down the fixes)
Hoping this goes well!
Just wondering... is it good/bad practice to rely on CDNs for some stuff like fonts and JS frameworks? I keep thinking that there might be some oddball case where the user's network blocked Google for whatever reason.
I have interviews on a regular basis since I do a lot of freelance work.
I wouldn't barge in telling them how to improve their codebase.
Generally I prepare a list of projects I want to show off beforehand, then run through them explaining their functionality and some of the technologies I used to build them.
Sometimes it's just the company boss or some hr-person interviewing - if they have any developers in the meeting it's good to give them some more in depth technical information.
Good luck!
If you don't enjoy HTML/CSS/JavaScript, or building websites, then yeah, webdev is probably not for you.
What is your motivation to do it if you don't enjoy it?
My roommate loves HTML/CSS/SASS/etc. and designing websites but doesn't like JavaScript. Despite my encouragement he's currently going through his own webdev crisis as well.If you don't enjoy HTML/CSS/JavaScript, or building websites, then yeah, webdev is probably not for you.
What is your motivation to do it if you don't enjoy it?