Javascript 在包含在两个不同HTML文件中的HTML文件中共享angularJS变量
在我的应用程序中,有不同的视图使用同一段代码。所以,我把这段代码放在一个名为sharedFile的文件中,所有变量和函数都有相同的名称,我检查了两次 这段代码可以显示一个过滤器框,用户可以在其中选择一些过滤器,应用它们,然后显示应用的不同过滤器。weel、HTTP请求等一切都可以正常工作,唯一的问题是我有一个“清除”按钮,可以一次删除所有过滤器,但实际上当我点击它时,过滤器不再出现在URL中(这是我想要的),但它们仍然显示 我在两个HTML文件之间共享这个文件,实际上其中一个工作得很好,但另一个只有在访问的前一个页面第一次工作时才工作 有什么想法或建议吗 谢谢 我把我的代码放在它可以帮助的地方:)Javascript 在包含在两个不同HTML文件中的HTML文件中共享angularJS变量,javascript,html,angularjs,include,Javascript,Html,Angularjs,Include,在我的应用程序中,有不同的视图使用同一段代码。所以,我把这段代码放在一个名为sharedFile的文件中,所有变量和函数都有相同的名称,我检查了两次 这段代码可以显示一个过滤器框,用户可以在其中选择一些过滤器,应用它们,然后显示应用的不同过滤器。weel、HTTP请求等一切都可以正常工作,唯一的问题是我有一个“清除”按钮,可以一次删除所有过滤器,但实际上当我点击它时,过滤器不再出现在URL中(这是我想要的),但它们仍然显示 我在两个HTML文件之间共享这个文件,实际上其中一个工作得很好,但另一个
队列
{{queue.name}
{{queue.name}
票证类型
{{type.name}
{{type.name}
适用于—
队列:
{{queue.name}
-
类型:
{{type.name}
-
你能发布控制器和app.js吗?另外,它在一个视图中工作这一事实并不影响它在另一个视图中的工作。请将其缩小到问题的最小表示形式,并显示它是如何共享的,以及控制器和视图的具体冲突发生在何处Hi,实际上我只是硬重设了我所做的,甚至在我尝试实现新的过滤器之前,我就意识到问题已经存在了。可能是由于HTTP请求的处理方式。。我会想办法的,谢谢你的回答:)
<!-- Enables the user to choose which filter he wants to be applied -->
<div ng-show=" show.filterBox" >
<div>
<strong>QUEUES</strong>
</div>
<span ng-repeat='queue in queues'>
<button href="" class="btn btn-sm marginButton btn-default" ng-click="onAddQueueFilter(queue.id.toString())" ng-hide="routeParams.queue_id && isIdInRouteParams('queue_id',queue.id)">
{{queue.name}}
<span class="glyphicon glyphicon-record"></span>
</button>
<button href="" class="btn btn-sm marginButton btn-primary text-muted" ng-click="onRemoveQueueFilter(queue.id.toString(), true)" ng-show="routeParams.queue_id && isIdInRouteParams('queue_id',queue.id)">
{{queue.name}}
<span class="glyphicon glyphicon-ok"></span>
</button>
</span>
<div>
<strong>TICKET TYPES</strong>
</div>
<span ng-repeat='type in types'>
<button href="" class="btn btn-sm marginButton btn-default" ng-click="onAddTypeFilter(type.id.toString())" ng-hide="routeParams.type_id && isIdInRouteParams('type_id',type.id)">
{{type.name}}
<span class="glyphicon glyphicon-record"></span>
</button>
<button href="" class="btn btn-sm marginButton btn-primary text-muted" ng-click="onRemoveTypeFilter(type.id.toString(), true)" ng-show="routeParams.type_id && isIdInRouteParams('type_id',type.id)">
{{type.name}}
<span class="glyphicon glyphicon-ok"></span>
</button>
</span>
<div>
<button class="btn btn-sm btn-success" ng-click="applyFilterBox()">Apply</button> - <a href='' ng-click='openCloseFilterBox()'>cancel</a>
</div>
<div ng-show="!show.filterBox ">
<div ng-show="routeParams.queue_id">
<!-- indicate that the list is queue list when status and queue list are shown -->
<span ng-show="routeParams.type_id" class="text-muted">queue:</span>
<span class="label label-primary label-status-id small-margin-top" ng-repeat="queue in queues" ng-show="routeParams.queue_id && isIdInRouteParams('queue_id',queue.id)">
{{queue.name}}
<span class="glyphicon glyphicon-remove"
style='font-size:0.7em; cursor:pointer'
ng-click='onRemoveQueueFilter(queue.id.toString(), false)'/>
</span>
<span ng-hide="!routeParams.queue_id" class='small-margin-top'>
-
<a href="" ng-click="location.search('queue_id',null);">clear</a>
</span>
</div>
<div ng-show="routeParams.type_id">
<span ng-show="routeParams.queue_id" class="text-muted">type:</span>
<span class="label label-info label-status-id small-margin-top" ng-repeat="type in types" ng-show="routeParams.type_id && isIdInRouteParams('type_id',type.id)">
{{type.name}}
<span class="glyphicon glyphicon-remove"
style='font-size:0.7em; cursor:pointer'
ng-click='onRemoveTypeFilter(type.id.toString(), false)'/>
</span>
<span ng-hide="!routeParams.type_id" class='small-margin-top'>
-
<a href="" ng-click="location.search('type_id',null);">clear</a>
</span>
</div>