我为 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 不想将我的控制器注入到应用程序中。如何将控制器移动到单独的文件并在我的视图中链接到这个文件?是否可以?
请原谅我的英语。问候,安东