0

Here i like to explain my problem clearly. Am not able to display image using from angularJS path from Json and Image stored in local folder

HTML

<div controller="canController">
<tr ng-repeat="can in canList">
    <td>{{can.can_name}}</td>
    <td><img ng-src="{{can.can_path}}" alt="{{can.can_name}}"></td>
</tr>
</div>

canController.js

$http.get('/auth/canUploadList').success(function(response){
            $scope.canList = response;
            console.log($scope.canList);
        }); 

JSON:

[
{
_id: "5672747ab0c1a0841314bf76",
can_path: "uploads/1450341498134-Bisleri.jpg",
can_name: "Hapserve",
__v: 0,
date: "2015-12-17T08:38:18.149Z"
},
{
_id: "56728c05a14c24701299fb52",
can_path: "uploads/1450347525373-Kinley.png",
can_name: "Kinley",
__v: 0,
date: "2015-12-17T10:18:45.397Z"
}
]

getting Output like this: output_image

Help me to sort out this problem

Updated:

router.get('/canUploadList', function(req, res){
        Can.find(function(err, docs){
            res.json(docs);
        });
    });



router.post('/canUpload', upload.single('can_image'), function(req, res, next) {
        console.log(req.body);
        console.log(req.file);
        var newCan = Can();
        newCan.can_name = req.body.can_name;
        newCan.can_path = 'uploads/' + req.file.filename;
        console.log(newCan.can_path);
        newCan.save(function(err, docs){
            if(err)
                throw err;
            else
                res.redirect('/auth/canUpload');
        });
    });
0

1 Answer 1

1
<td><img ng-show="{{can.can_path}}" alt="{{can.can_name}}"></td> 

to

<td><img ng-src="{{can.can_path}}" alt="{{can.can_name}}"></td>

try this. change ng-show to ng-src

Sign up to request clarification or add additional context in comments.

8 Comments

can you try and check if image opens in browser. to crossverify its not broken
yeah not opening in browser
then some problem with data not code.. if it working with proper image do accept answer. thanks.
server code why? you see in console.log that you have put that values are coming
where are those images ? is your backend and front end server same... do you have folder named uploads on your front end server root with those images ?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.