read a local file in angular js

745 views
Skip to first unread message

rangil...@gmail.com

unread,
Sep 11, 2015, 10:34:37 AM9/11/15
to AngularJS
Hi,

what is the best way to read a local file and search for a string and display it in the 
browser using angularjs? is it by using a directive?

Thanks in advance

Sander Elias

unread,
Sep 11, 2015, 11:06:23 AM9/11/15
to AngularJS
Hi,

What do you need, you want your use to be able to drop an file into your app or what?
Reading the local file system from within the browser is impossible. (well, for a web-app it is) 

Regards
Sander

Jayashree M A

unread,
Sep 11, 2015, 11:26:35 AM9/11/15
to ang...@googlegroups.com
Hi.

Actually the file can be local or remote. Can i use the $http service to read the
file contents and then display the filtered contents? I don't need to do drag and
drop

Thanks in advance


--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/bmB5yiWjZT0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Thế Bảo Đinh

unread,
Sep 11, 2015, 11:55:30 AM9/11/15
to AngularJS
Yes, you can use it . It is the code i used:
       obj.getCustomers = function(){
return $http.get("data/data.xml");
}

        services.getCustomers().then(function(data){
var source = x2js.xml_str2json(data.data);
angular.forEach(cartItems,function(value,key){

var item = ($filter('filter')(source.data.item, {id: value }));

shopItems.push(item[0]);
});
$scope.shopItems = shopItems;
});

Erick Engelhardt

unread,
Sep 11, 2015, 12:34:43 PM9/11/15
to AngularJS

You should seek some integration with Java applets, activex...

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

Sander Elias

unread,
Sep 11, 2015, 10:36:27 PM9/11/15
to AngularJS
hi Jayashree,

You can't read local files with $http. Only remote is possible (you can make local files remote, by starting a http-server) If you are developing an desktop(like) app have a look at nw. If you google around a bit, you will find plenty alternatives for both of these.

Regards
Sander

Alain Ekambi

unread,
Sep 12, 2015, 2:54:33 AM9/12/15
to ang...@googlegroups.com

If u are willing to use a bit of flash then it s possible to read local files. Does not html5 file reader do that to ?

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

Jayashree M A

unread,
Sep 12, 2015, 3:56:58 AM9/12/15
to ang...@googlegroups.com
Hi,


As I am quite new to angular js I have not understood the code sent by bao dinh.
Could someone spoon feed me and give me the model, view and controller code
from scratch for searching for a string in a file and displaying it's contents

Thanks
Reply all
Reply to author
Forward
0 new messages