2016-06-19 12 views
0

Laravelで単純な角度コードの作業を行うことはできませんが、私はそれをcodepenでテストしても機能します。角度がlaravelで機能していない

私のギャルプには角があります。そして、私はまた、他のすべてのスクリプトをコメントして(そして既にコピーされたスクリプトをresources/jsディレクトリから削除して)、角度だけでテストしてみました。出力Webページで

gulp.js

elixir(function(mix) { 
mix 
// .copy('vendor/bower_components/jquery/dist/jquery.js', 'resources/js/1-jquery.js') 
// .copy('vendor/bower_components/bootstrap/dist/js/bootstrap.js', 'resources/js/2-bootstrap.js') 
    .copy('vendor/bower_components/angular/angular.js', 'resources/js/3-angular.js') 
// .copy('vendor/bower_components/lightgallery/dist/js/lightgallery-all.js', 'resources/js/4-lightgallery.js') 
// .copy('vendor/bower_components/lightslider/dist/js/lightslider.js', 'resources/js/5-lightslider.js') 

    .scriptsIn('resources/js') 
    .version([ 
     'public/css/app.css', 
     'public/js/all.js' 
     ]) 
}); 

blade.php

{!! Form::open(array('route' => 'order', 'class' => 'go-right calculator', 'files' => true, 'ng-app' => 'SaunaDoorCalc', 'ng-controller' => 'SaunaDoorCalcController')) !!} 

    <div class="form-group door_size_radio col-xs-12 col-sm-6" style="margin-bottom:67px;"><h4>Размер дверной коробки (в миллиметрах)</h4> 
     <div ng-repeat="a in sizeswitch" class="form-group"> 
     <input type="radio" value="@{{a.value}}" name="door_size_radio" class="radio"> 
     <label for="door_size_radio" class="radio">@{{a.label}}</label> 
     </div> 
    </div> 
{!! Form::close() !!} 

app.js

angular 
    .module('SaunaDoorCalc',[]) 
    .controller('SaunaDoorCalcController', function($scope) { 

    $scope.sizeswitch = [   
     { value: 'standard', label: 'Стандартный' }, 
     { value: 'special', label: 'Ввести размер' } 
    ]; 


    $scope.submit = function() { 
     alert('submit'); 
    }; 


    $scope.myDate = new Date(); 
    $scope.minDate = new Date(
     $scope.myDate.getFullYear(), 
     $scope.myDate.getMonth() - 2, 
     $scope.myDate.getDate()); 
    $scope.maxDate = new Date(
     $scope.myDate.getFullYear(), 
     $scope.myDate.getMonth() + 2, 
     $scope.myDate.getDate()); 
    $scope.onlyWeekendsPredicate = function(date) { 
    var day = date.getDay(); 
    return day === 0 || day === 6; 
    } 
    }); 

I {{a.label}}と2回ではなく1回だけを参照してください。

私は、角、コンソールエラーで

Error: [$injector:modulerr] Failed to instantiate module app due to: 
[$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. 
http://errors.angularjs.org/1.5.6/$injector/nomod?p0=app 
minErr/<@http://site.dev/build/js/all-6fc346934b.js:12247:12 
module/<@http://site.dev/build/js/all-6fc346934b.js:14280:17 
[email protected]://site.dev/build/js/all-6fc346934b.js:14204:38 
[email protected]://site.dev/build/js/all-6fc346934b.js:14278:14 
loadModules/<@http://site.dev/build/js/all-6fc346934b.js:16786:22 
[email protected]://site.dev/build/js/all-6fc346934b.js:12501:11 
[email protected]://site.dev/build/js/all-6fc346934b.js:16770:5 
[email protected]://site.dev/build/js/all-6fc346934b.js:16692:19 
bootstrap/[email protected]://site.dev/build/js/all-6fc346934b.js:13956:20 
[email protected]://site.dev/build/js/all-6fc346934b.js:13977:12 
[email protected]://site.dev/build/js/all-6fc346934b.js:13862:5 
@http://site.dev/build/js/all-6fc346934b.js:43197:5 
jQuery.Callbacks/[email protected]://site.dev/build/js/all-6fc346934b.js:3187:11 
jQuery.Callbacks/[email protected]://site.dev/build/js/all-6fc346934b.js:3317:7 
[email protected]://site.dev/build/js/all-6fc346934b.js:3536:3 
[email protected]://site.dev/build/js/all-6fc346934b.js:3552:2 
+0

ここには何が入っていますか? –

+0

はい。そこに何かがある。最初の投稿に追加 – schel4ok

答えて

0

jsのセクションでは、このエラーを検出しましたがappと呼ばれるモジュールを探しています。あなたのビューファイルのどこかにおそらくng-app="app"を使用しますが、モジュールを作成していません。

以下のいずれかの方法をお試しください。

解決方法1:

あなたの角度アプリをブートストラップビューファイルで、あなたが作成したモジュールの名前にNG-アプリの値を変更します。

<body ng-app="SaunaDoorCalc"> 

解決方法2:

はapp.jsでは、SaunaDoorCalcからappにあなたのモジュール名を変更するには、bodyタグのあなたのアプリをブートストラップして、メインモジュールがSaunaDoorCalcと呼ばれていると仮定すると。

angular 
    .module('app',[]) 
    .controller('SaunaDoorCalcController', function($scope) { 
    // your code here 
} 
+0

あなたは正しいです。ありがとう! – schel4ok

+0

何か助けになることを嬉しく思います。 –

関連する問題