2

Umbraco 7 バックエンド用の新しいカスタム セクションを作成しました。これで、コードを使用して edit.html ファイル プロパティ エディターの目的を作成しました。

<script type="text/javascript">
function CustomSectionEditController($scope, $log, $routeParams) {
    $scope.content = { tabs: [{ id: 1, label: "Tab 1" }, { id: 2, label: "Tab 2" }] };

    $scope.EditMode = function () {
        $log.warn($routeParams);
        return $routeParams.create == 'true';
    };
}
</script>

<div ng-controller="CustomSectionEditController">
    <umb-panel>
        <umb-header tabs="content.tabs">
            <div class="umb-headline-editor-wrapper span12 ng-scope">
                <h1 class="ng-binding">My custom section {{id}}</h1>
            </div>
        </umb-header>

        <umb-tab-view>
            <umb-tab id="tab1" rel="svensson">

                <div class="umb-pane">
                    This is tab content for tab 1<br />
                    <p ng-show="EditMode()">
                        <span class="label label-warning">In create mode, this label is only showed when the controller sees the create-querystring item.</span>
                    </p>
                </div>
            </umb-tab>

            <umb-tab id="tab2" rel="kalle">

                <div class="umb-pane">

                    This is tab content for tab 2
                </div>
            </umb-tab>

        </umb-tab-view>
    </umb-panel>

</div>

うまく機能しますが、ビジネスロジックをビューから別のファイルに移動したいです。JS コードを別のファイルに移動して、次のようにリンクしようとしました。

<script type="text/javascript" src="Controllers/StoreEditController.js"></script>

そして、Angular は私のコントローラーをアプリに挿入したくありません。コントローラーを別のファイルに移動して、ビューでこれにリンクするにはどうすればよいですか? 出来ますか?

すみません、英語でお願いします。よろしく、 アントン

4

2 に答える 2

0

依存関係の挿入には、必ずミニフィケーション セーフな構文を使用してください。

angular.module("umbraco")
  .controller("ExampleController",
  ['$scope', '$log', function($scope, $log) {
    //do some stuff
  }]);

また、次の内容の package.manifest ファイルを App_Plugins/YourPlugin/ の直下に追加します。

{   
    //array of files we want to inject into the application on app_start
    javascript: [
        '~/App_Plugins/YourPlugin/path/to/jsfile.js'
    ]
}

これが私が見つけた最良の例です:

UkFest-AngularJS-デモ

于 2015-01-07T19:04:26.550 に答える