Skip to content

Angular2+ can't load proto files #1040

Closed
@her-m

Description

@her-m

protobuf.js version: <6.8.6>

Hello, I'm trying to integrate Protobuf.js in my Angular 4 project. I'm following the example on the Github page and generated my .proto file. I'm stuck on trying to load my proto file which is in the same folder as my .ts file. I also tried #797 but the result is the same.

image

Here's a small snippet of what I'm trying to do.

import { Injectable } from '@angular/core';
import * as protobuf from 'protobufjs';

@Injectable()

export class ProtobufService {
    constructor() {
        protobuf.configure();
    }

    start() {
        protobuf.load('./awesome.proto', function(err, root) {
    }
}

And the result I get. I tried including the relative and absolute paths and no success.

GET http://localhost:4200/awesome.proto 404 (Not Found)
ERROR Error: status 404
    at XMLHttpRequest.fetchOnReadyStateChange [as __zone_symbol__ON_PROPERTYreadystatechange] (index.js:90)

Any idea ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions