点击后如何打开离子模式?(How to open up an Ionic Modal upon click?)
我是Ionic和AugularJS的新手,在点击设置页面中的第三个选项进行hashtag search的复选框/单选按钮时,我遇到了打开模式框的问题。 我已经包含一个
ng-controller
和ng-click
来采取行动。 我看着调试器,它显示一个错误:
GET http://localhost:8100/hashtag-modal [HTTP/1.1 404 Not Found 1ms]
我知道404未找到意味着它没有找到templateUrl,但我拥有的每个导航页面都在index.html中,并且除了
app.js
文件中的hashtag-modal.html
外,它们hashtag-modal.html
正常工作。 为什么它不工作,我该如何解决这个问题?app.js
// Navigation pages app.config(function($stateProvider, $urlRouterProvider) { $stateProvider .state('index', { url: '/index', templateUrl: 'index.html' }) .state('about', { url: '/about', templateUrl: 'about.html' }) .state('settings', { url: '/settings', templateUrl: 'settings.html' }) .state('hashtag-modal', { url: '/hashtag-modal', templateUrl: 'hashtag-modal', controller: 'hashtag-modalCtrl' }) $urlRouterProvider.otherwise("/index"); // if no url found, go back to index }) // Hashtag Search option app.controller('hashtagController', ['$scope', function($scope) { $scope.hashtagValue = 'Search'; // default value $scope.hashtag = function() { $scope.hashtagValue = 'blackandwhitephotography'; // if selected, it'll display this value }; }]); // hashtag search modal app.controller('hashtag-modalCtrl', function($scope, $ionicModal) { $ionicModal.fromTemplateUrl('hashtag-modal.html', { scope: $scope, animation: 'slide-in-up', focusFirstInput: true }).then(function(modal) { $scope.modal = modal; }); $scope.openModal = function() { $scope.modal.show(); }; $scope.closeModal = function() { $scope.modal.hide(); }; // Cleanup the modal when we're done with it! $scope.$on('$destroy', function() { $scope.modal.remove(); }); // Execute action on hide modal $scope.$on('modal.hidden', function() { // Execute action }); // Execute action on remove modal $scope.$on('modal.removed', function() { // Execute action }); });
的index.html
<!-- SETTINGS --> <script id="settings.html" type="text/ng-template"> <!-- The title of the ion-view will be shown on the navbar --> <ion-view title="Settings" hide-back-button="false"> <ion-content class="padding"> <!-- The content of the page --> <p>Check one of the options below to set how you wish to categorize and view your Instagram photos. </p> <div class="settings-list"> <label class="item item-radio"> <input type="radio" name="settings-group" value="recent"> <div class="item-content"> Recent </div> <i class="radio-icon ion-checkmark"></i> </label> <label class="item item-radio"> <input type="radio" name="settings-group" value="popular"> <div class="item-content"> Most Popular </div> <i class="radio-icon ion-checkmark"></i> </label> <label class="item item-radio" id="hashtagRadio" ng-controller="hashtagController" ng-click="hashtag();modal.show();"> <input type="radio" name="settings-group" value="search"> <div class="item-content"> <span class="ion-pound"></span> <span id="hashtagInput">{{hashtagValue}}</span> </div> <i class="radio-icon ion-checkmark"></i> </label> </div> </ion-content> </ion-view> </script> <!-- HASHTAG SEARCH MODAL --> <script id="hashtag-modal.html" type="text/ng-template"> <ion-modal-view hide-back-button="false"> <ion-header-bar> <h1 class="title">Hashtag Search</h1> </ion-header-bar> <ion-content> <label class="item item-input"> <i class="icon ion-search placeholder-icon"></i> <input type="search" placeholder="Search"> </label> </ion-content> </ion-modal-view> </script>
修改后的app.js
我在
hashtagController
添加了一个$ionicModal
,但据说Error: $ionicModal is undefined
。 还有哪些地方没有定义?// Hashtag Search option app.controller('hashtagController', ['$scope', function($scope, $ionicModal) { $scope.hashtagValue = 'Search'; // default value $scope.hashtag = function() { $scope.hashtagValue = 'blackandwhitephotography'; // if selected, it'll display this value $ionicModal.fromTemplateUrl('hashtag-modal.html', { scope: $scope, animation: 'slide-in-up', focusFirstInput: true }).then(function(modal) { $scope.modal = modal; }); $scope.openModal = function() { $scope.modal.show(); }; $scope.closeModal = function() { $scope.modal.hide(); }; // Cleanup the modal when we're done with it! $scope.$on('$destroy', function() { $scope.modal.remove(); }); // Execute action on hide modal $scope.$on('modal.hidden', function() { // Execute action }); // Execute action on remove modal $scope.$on('modal.removed', function() { // Execute action }); } }]);
修订后的标签
<label class="item item-radio" id="hashtagRadio" ng-controller="hashtagController" ng-click="hashtag();openModal();"> <input type="radio" name="settings-group" value="search"> <div class="item-content"> <span class="ion-pound"></span> <span id="hashtagInput">{{hashtagValue}}</span> </div> <i class="radio-icon ion-checkmark"></i> </label>
I am new to Ionic and AugularJS and I am having a problem opening up a modal box upon click on a checkbox/radio button on the third option for hashtag search in the settings page. I have included an
ng-controller
andng-click
to take action. I looked in the debugger and it displayed an error:
GET http://localhost:8100/hashtag-modal [HTTP/1.1 404 Not Found 1ms]
I know that 404 Not Found means it didn't find the templateUrl but every nav page I have is in the index.html and they work fine except
hashtag-modal.html
in theapp.js
file. Why isn't it working and how do I resolve this issue?app.js
// Navigation pages app.config(function($stateProvider, $urlRouterProvider) { $stateProvider .state('index', { url: '/index', templateUrl: 'index.html' }) .state('about', { url: '/about', templateUrl: 'about.html' }) .state('settings', { url: '/settings', templateUrl: 'settings.html' }) .state('hashtag-modal', { url: '/hashtag-modal', templateUrl: 'hashtag-modal', controller: 'hashtag-modalCtrl' }) $urlRouterProvider.otherwise("/index"); // if no url found, go back to index }) // Hashtag Search option app.controller('hashtagController', ['$scope', function($scope) { $scope.hashtagValue = 'Search'; // default value $scope.hashtag = function() { $scope.hashtagValue = 'blackandwhitephotography'; // if selected, it'll display this value }; }]); // hashtag search modal app.controller('hashtag-modalCtrl', function($scope, $ionicModal) { $ionicModal.fromTemplateUrl('hashtag-modal.html', { scope: $scope, animation: 'slide-in-up', focusFirstInput: true }).then(function(modal) { $scope.modal = modal; }); $scope.openModal = function() { $scope.modal.show(); }; $scope.closeModal = function() { $scope.modal.hide(); }; // Cleanup the modal when we're done with it! $scope.$on('$destroy', function() { $scope.modal.remove(); }); // Execute action on hide modal $scope.$on('modal.hidden', function() { // Execute action }); // Execute action on remove modal $scope.$on('modal.removed', function() { // Execute action }); });
index.html
<!-- SETTINGS --> <script id="settings.html" type="text/ng-template"> <!-- The title of the ion-view will be shown on the navbar --> <ion-view title="Settings" hide-back-button="false"> <ion-content class="padding"> <!-- The content of the page --> <p>Check one of the options below to set how you wish to categorize and view your Instagram photos. </p> <div class="settings-list"> <label class="item item-radio"> <input type="radio" name="settings-group" value="recent"> <div class="item-content"> Recent </div> <i class="radio-icon ion-checkmark"></i> </label> <label class="item item-radio"> <input type="radio" name="settings-group" value="popular"> <div class="item-content"> Most Popular </div> <i class="radio-icon ion-checkmark"></i> </label> <label class="item item-radio" id="hashtagRadio" ng-controller="hashtagController" ng-click="hashtag();modal.show();"> <input type="radio" name="settings-group" value="search"> <div class="item-content"> <span class="ion-pound"></span> <span id="hashtagInput">{{hashtagValue}}</span> </div> <i class="radio-icon ion-checkmark"></i> </label> </div> </ion-content> </ion-view> </script> <!-- HASHTAG SEARCH MODAL --> <script id="hashtag-modal.html" type="text/ng-template"> <ion-modal-view hide-back-button="false"> <ion-header-bar> <h1 class="title">Hashtag Search</h1> </ion-header-bar> <ion-content> <label class="item item-input"> <i class="icon ion-search placeholder-icon"></i> <input type="search" placeholder="Search"> </label> </ion-content> </ion-modal-view> </script>
Revised app.js
I added an
$ionicModal
to thehashtagController
but it is saidError: $ionicModal is undefined
. Where else is it undefined?// Hashtag Search option app.controller('hashtagController', ['$scope', function($scope, $ionicModal) { $scope.hashtagValue = 'Search'; // default value $scope.hashtag = function() { $scope.hashtagValue = 'blackandwhitephotography'; // if selected, it'll display this value $ionicModal.fromTemplateUrl('hashtag-modal.html', { scope: $scope, animation: 'slide-in-up', focusFirstInput: true }).then(function(modal) { $scope.modal = modal; }); $scope.openModal = function() { $scope.modal.show(); }; $scope.closeModal = function() { $scope.modal.hide(); }; // Cleanup the modal when we're done with it! $scope.$on('$destroy', function() { $scope.modal.remove(); }); // Execute action on hide modal $scope.$on('modal.hidden', function() { // Execute action }); // Execute action on remove modal $scope.$on('modal.removed', function() { // Execute action }); } }]);
Revised label
<label class="item item-radio" id="hashtagRadio" ng-controller="hashtagController" ng-click="hashtag();openModal();"> <input type="radio" name="settings-group" value="search"> <div class="item-content"> <span class="ion-pound"></span> <span id="hashtagInput">{{hashtagValue}}</span> </div> <i class="radio-icon ion-checkmark"></i> </label>
原文:https://stackoverflow.com/questions/27285472
最满意答案
我认为它还没有实现($ psise)。 您可以在VSCode的vscode-powershell Project上提出问题。 类似的一个已经提交。
至少你可以使用像
$context = [Microsoft.Powershell.EditorServices.Extensions.EditorContext]$psEditor.GetEditorContext()
然后你可以访问当前文件...
$context.CurrentFile.
有关介绍,另请参阅此视频 ...
I think it's not implemented yet (the $psise). You can file an issue on the vscode-powershell Project for VSCode. A similar one has already been filed.
At least you might use something like
$context = [Microsoft.Powershell.EditorServices.Extensions.EditorContext]$psEditor.GetEditorContext()
Then you can access the current file...
$context.CurrentFile.
See also this video for an introduction...
相关问答
更多-
我认为它还没有实现($ psise)。 您可以在VSCode的vscode-powershell Project上提出问题。 类似的一个已经提交。 至少你可以使用像$context = [Microsoft.Powershell.EditorServices.Extensions.EditorContext]$psEditor.GetEditorContext() 然后你可以访问当前文件... $context.CurrentFile. 有关介绍,另请参阅此视频 ... I think it's not i ...
-
Visual Studio代码和Visual Studio有什么区别?(What are the differences between Visual Studio Code and Visual Studio?)[2022-10-15]
Visual Studio(完整版)是一个“全功能”和“方便”的开发环境。 Visual Studio(免费的“Express”版本 - 直到2015年)是功能集中和完整版本的简化版本。 以不同版本(Visual Studio Web Developer,Visual Studio C#等)为特征为中心的意图取决于您的目标。 Visual Studio(免费社区版 - 自2015年以来)是完整版本的简化版本,取代了2015年之前使用的分开的快速版本。 Visual Studio代码(VSCode)是一个跨平 ... -
代码格式可通过以下快捷方式在VS代码中使用: 在Windows Shift + Alt + F 在Mac Shift + Option + F 在Ubuntu上Ctrl + Shift + I 或者,您可以通过Ctrl + Shift + P (或Mac上的Command + Shift + P )编辑器中提供的搜索功能找到快捷方式以及其他快捷方式,然后搜索格式文档 。 The code formatting is available in Visual Studio Code through the fo ...
-
是否有Eclipse等效的Visual Studio片段?(Is there an Eclipse equivalent of Visual Studio snippets?)[2023-06-06]
是的,有。 您可以选择Window> Preferences对话框来访问现有的那些。 然后导航到Java> Editor> Templates子树。 在那里你可以看到现有的。 第一列是名称和激活码。 例如,“main”模板在光标位置插入默认主块。 您可以在编辑器中输入“main”并按“CTRL + space”。 然后会显示一个弹出窗口,您可以选择所需的模板。 在上述对话框中,您既可以定义新模板,也可以随意编辑现有模板。 需要考虑的一件事是,如果光标位于第二列中指示的上下文中,则内容辅助(CTRL +空格键 ... -
Visual Studio中的HotKey用于排列JavaScript代码(HotKey in Visual Studio to arrange the JavaScript code)[2022-07-01]
你可以下载一个扩展程序,它可以做到这一点: 它还有一个快捷键。 http://visualstudiogallery.msdn.microsoft.com/41a0cc2f-eefd-4342-9fa9-3626855ca22a There is an extension you can download which will do just that: It has a shortcut key as well. http://visualstudiogallery.msdn.microsoft.com/ ... -
这个问题在这里和这里已经有了答案。 差异列表非常庞大。 Visual Studio Code是Microsoft为Windows,Linux和MacOS开发的源代码编辑器,重点在于编写代码,而不是处理调试,编译,测试,重构以及所有使Visual Studio更好的其他功能。 使用Visual Studio代码的人可能是Mac上的人,他们只会处理客户端技术(HTML / JS / CSS),并且不想安装Windows来执行此操作。 使用Windows并开发C#,F#或VB的用户将继续使用Visual Stud ...
-
我会建议使用: Git Lens 。 UPDATE Now it's available: https://marketplace.visualstudio.com/items?itemName=donjayamanne.githistory until now it isn't supported, but can follow the thread for it: github
-
不幸的是Javascript不支持这个。 您可以通过评论进行分离。 /*My Region (Name It)*/ your scripts /*End Region*/ 或者你可以看到这个线程如何做到这一点。 如何在javascript中实现区域/代码崩溃 Unfortunately Javascript don't support this. You can do the separation by comments. /*My Region (Name It)*/ your scripts /*En ...
-
Visual Studio Code和Visual Studio使用相同的编译器吗?(Do Visual Studio Code and Visual Studio use the same compiler?)[2022-07-11]
Visual Studio Code使用Roslyn平台(参见此处 )。 与Visual Studio 2015相同。在Linux和OS X上使用Mono编译器。 IDE本身如果基本上是GitHub Atom的扩展(这很棒),当然,它甚至不会接近完整Visual Studio的强大功能。 但它非常干净,易于使用。 特别是新的ASP.NET 5 Web应用程序非常像Node.js / Angular / etc应用程序,许多人在Sublime和Atom等简单的编辑器中编写这些应用程序。 更新: 它周围的工具并 ... -
Visual Studio(VS)和Visual Studio Code(VSCode)是完全不同的产品。 他们不是真正的竞争者。 VS是一个完整的IDE,带有编译器,调试器,库,项目模板等。它只能在Windows和MacOS机器上运行。 VSCode是一个专为编码人员设计的轻量级文本编辑器。 它支持许多不同的文件类型,可以附加到编译器和调试器,但它不附带任何编译器或库。 它在所有桌面平台上运行。 当您想要维护C#或C ++项目时,VSCode可以成为VS的良好伴侣。 如果您想编写JavaScript,Ty ...