简体   繁体   中英

Angular 1.x component templateUrl not rendering in DOM

I have my component setup like so:

// app/my-component/my-component.js
app.component('myComponent', {
    bindings: {
        bindingA: '=',
        bindingB: '='
    },
    templateUrl: 'app/my-component/my-component.tpl.html',
    controller: MyComponentCtrl
});

// app/my-component/my-component.tpl.html
<div>
    <input type="text" ng-model="$ctrl.bindingA" />
    <input type="text" ng-model="$ctrl.bindingB" />
</div>

No errors are thrown; my template file shows up just fine in Chrome's Dev Tools. Network preview of the XHR request shows up right but it just won't render on the DOM...

If I swap out templateUrl with template , the string will display just fine in the DOM.

Any ideas?

After wanting to beat my head on the keyboard, I realized that this bit of code was interfering will the templateUrl responses:

$httpProvider.interceptors.push(function() {
    return {
            'response': function (response) {
                response.data = response.data.d;

                return response;
            }
        }
    });

Simply changed to: if (response.data.d) response.data = response.data.d;

Another day in the life I'll tell ya...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM