- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的模式有一个 windowTemplateUrl,如下所示
<div tabindex="-1" role="dialog" class="modal fade" ng-class="{in: animate}" ng-style="{'z-index': 1050 + index*10, display: 'block'}" data-ng-click="close($event)">
<div class="modal-dialog" ng-class="{'modal-sm': size == 'sm', 'modal-lg': size == 'lg'}">
<div class="modal-content square-btn">
<div class="modal-header custom-modal-header square-btn">
<button type="button" class="close" data-dismiss="modal" ng-click="cancel($event)">
<span aria-hidden="true">×</span>
<span class="sr-only">Close</span>
</button>
<h3 class="modal-title">{{modalTitle}}--</h3>
</div>
<div class="modal-body" modal-transclude>
</div>
</div>
</div>
</div>
我的js代码如下
$modal.open({
windowTemplateUrl: 'templates/common/modal.html',
templateUrl: 'templates/jobs/create-job-modal.html',
resolve: {
modalTitle: function(){
return 'Create new position';
}
},
controller: ['$scope', 'modalTitle', function( $scope, modalTitle ) {
$scope.modalTitle = modalTitle;
}]
});
但似乎无法从 modal.html
模板访问我的范围。但我可以从 create-job-modal.html
模板访问它。我在 modal.html 中需要它。
我怎样才能做到这一点。提前致谢
最佳答案
这有点违反直觉,但 Controller 的作用域实际上是 windowTemplate 的父作用域。
因此,您可以通过在 windowTemplate 中执行 $parent.modalTitle 来访问 modalTitle。
关于javascript - 以 Angular 访问窗口 TemplateUrl 内的范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27702427/
我是 AngularJs 的新手。我正在编写我的自定义 angular 指令,其中包含一些 html 内容的模板。当我使用带有以下代码的模板时,它工作正常。 demoApp.directive('de
我的 AngularJS 路由有问题:我没有得到任何页面反馈。没有错误或 View 切换。 我检查了模块的实现,但它以正确的方式声明。然后我搜索了诸如templateURL之类的错别字。 ,但我没有找
当 templateUrl 分配给指向 Controller 的路由时导致 404 错误或 500 错误时,有谁知道如何在 AngularJS 中捕获错误?当发生故障时,我在控制台中看到了问题,但我似
刚接触 angular,在过去一个小时左右的时间里,我一直在处理什么应该是一个简单的指令时遇到问题。真的很感激一些帮助! 我相信你好应该出现,似乎无法让它工作? 测试.html
我正在处理一组 Angular 指令,我想根据属性的存在或值加载正确的模板。 如果是水平的,templateUrl 应该是 /partials/horizontal-form和 如果是垂直的,
标题组件 import { Component } from "angular2/core"; @Component({ selector: "header-component", t
这个问题已经有答案了: Dynamic template URLs in Angular 2 (10 个回答) 已关闭 6 年前。 我想知道是否可以制作templateUrl取决于ifelse . i
我有一个如下所示的 html 元素: 我想让我的指令根据 type 是什么使用不同的 templateUrl。 appDirectives.directive('newElement', funct
这是我的自定义指令 centraApp.directive('counter', function () { return { restrict: 'A', s
我真的需要解决以下问题的帮助: 我尝试实现应用程序的一些设置,因此我想使用UI-Bootstrap Accordion 。 我有以下HTML代码: “ Acc
我按照 angular.io 入门项目使用种子结构。到目前为止一切正常。 现在我想更改顶部组件以从单独的文件中获取 View ,但我遇到了麻烦。工作代码是: import {Component, Vi
我正在尝试在 Angular js 2 中使用以下代码加载 Html 文件。该文件位于产品文件夹下,我尝试加载的 html 文件也在同一文件夹中。仍然无法正常工作。 import {Component
我目前正在声明相对于当前窗口位置的 templateUrl。 cvApp.directive('personalDetails', function () { return {
是否可以将范围读入指令的 templateUrl 中? 我想做这样的事情: mDirective.directive('directive', [function () { return {
这是我的指令代码: // Generated by CoffeeScript 1.6.3 (function() { var autumnDirectives; autumnDirective
我有两个指令,我试图在另一个指令的 templateUrl 中使用某个属性调用一个指令,但我无法在第二个指令中获取已编译的属性值。代码是这样的: 第一个指令 app.directive('myDir'
考虑代码(Angular 1.2 RC3): main.config(['$routeProvider', '$sce', function($routeProvider, $sce) { $
我正在本地开发一个单页应用程序。 我似乎无法使用 Angularjs 中的简单自定义指令将 HTML 文件加载为模板。如果我尝试使用 使用原始 html template: 属性,它工作得很好,但我有
我似乎无法使用 angularjs 路由加载 templateUrl。 使用 django 和 angularjs。 我所做的就是转到 127.0.0.1:8000/phones/,它会将我重定向到
该模板甚至似乎没有被请求。我尝试了绝对 URL、相对 URL,甚至全长 URL。 我已经检查过,根本没有请求该模板。 这是代码: app.directive('field', function ()
我是一名优秀的程序员,十分优秀!