2017-03-28 9 views
0

角度指令テンプレートにいくつか問題があります。角度指令テンプレートがエラーを投げる

'use strict'; 

function HomeDirective() { 
    return { 
    controller: 'homeController', 
    template: require('./views/home.html'), 

    restrict: 'AEC', 
    scope: true 
    } 
} 

module.exports = HomeDirective; 

私は、ビューfolder.Myビュー内のテンプレートはエラーが私が使用したときに働いている

<div>                   
^                    
ParseError: Unexpected token               
at wrapWithPluginError (C:\Users\DAT-Asset-110\Desktop\Test 
Code\anguler_test_structure\node_modules\gulp-browserify\index.js:44:10) 

以下れる

<div> 
<p>This is Home Page.You can nevigate to any page</p> 
<p>The Content is {{test}}</p> 
</div> 

である必要があり

'use strict'; 

function HomeDirective() { 
    return { 
    controller: 'homeController', 

    template: '<div><p>This is Home Page.You can nevigate to any page</p> 
    <p>The Content is {{test}}</p></div>', 
    restrict: 'AEC', 
    scope: true 
    } 
} 

module.exports = HomeDirective; 

缶誰も私を助けます。問題は何ですか?それの解決策は何ですか?

+0

あなたのテンプレートを読み込むためにWebPACKのを使用していますか? 。そうでなければテンプレートではなくtemplateUrlでなければなりません。 –

+0

webpack.Iを使用して適切なリンクステップを送ることができますか?私はbrowserifyを使う@ ShushanthPallegar –

答えて

1

利用templateUrl代わりのテンプレート:templateUrl: 'views/home.html'

'use strict'; 

function HomeDirective() { 
    return { 
    controller: 'homeController', 
    templateUrl: 'views/home.html', 

    restrict: 'AEC', 
    scope: true 
    } 
} 

module.exports = HomeDirective; 
+0

あなたのanswer.whatはtemplateUrlの代わりにテンプレートを使用しています@Syed –

+0

は 'require( './ views/home)です。 html ')、 'htmlを返す関数? – madalinivascu

+0

これをチェック:http://stackoverflow.com/questions/33923630/how-to-use-both-gulp-babel-and-gulp-browserify – Syed

関連する問題