Angularjs ui.routing - 在将HTML呈现到ui-view之前,将属性添加到输入元素 [英] Angularjs ui.routing - add attribute to input elements before rendering HTML into ui-view
问题描述
我正在使用angular js - ui.router概念进行SinglePageApplication开发。
当我点击第1页和第2页链接时,其各自的html页面将呈现为'ui-view'div 。我想将data-ng-blur属性添加到相应的html页面(Sample.html,Sample2.html),输入控件,同时单击ui-sref链接。我已经在
中给出了两个htmls的文件就绪事件,但那并没有被解雇。因此,在ui-router调用各自的Controller之前,可以选择在加载html时为输入元素添加属性。
代码:
I am using angular js - ui.router concept for SinglePageApplication Development.
When i click Page 1 and Page 2 link, then its respective html page will be rendered into 'ui-view' div. I want to add 'data-ng-blur' attribute into respective html page(Sample.html, Sample2.html), input controls while click 'ui-sref' link. I have give Document ready events in
that both htmls, But that's not fired. So there is any option for add attributes for input elements in loading html before its respective Controller called by ui-router.
Code :
<div data-ng-app="ProjectApp">
<div class="menulist">
<li><a ui-sref="pageone">Page 1</a></li>
<li><a ui-sref="pagetwo">Page 2</a></li>
</div>
<div class="ui-view"></div>
<script>
var loApp = angular.module("ProjectApp", ["ui.router"]);
loApp.config(function ($urlRouterProvider, $stateProvider, $urlMatcherFactoryProvider) {
$urlMatcherFactoryProvider.caseInsenstiveMatch = true;
$stateProvider
.state('pageone', {
url: '/Screen-one',
templateUrl: 'Sample.html',
controller: pageoneCtrler
})
.state('pagetwo', {
url: '/Screen-two',
templateUrl: 'Sample2.html',
controller: pagetwoCtrler
});
});
loApp.controller("pageoneCtrler", function ($scope) {
$scope.myfunction = function(){
}
});
loApp.controller("pagetwoCtrler", function ($scope) {
});
</script>
</div>
我尝试过:
我试图在htmls(Sample.html,Sample2.html)中提供文档就绪事件,但是当在ui-view div中加载html时它不会被触发。
What I have tried:
I tried to give document ready events in that htmls(Sample.html, Sample2.html), but its not fired when html loading in ui-view div.
推荐答案
urlRouterProvider,
urlRouterProvider,
stateProvider,
stateProvider,
urlMatcherFactoryProvider){
urlMatcherFactoryProvider) {
这篇关于Angularjs ui.routing - 在将HTML呈现到ui-view之前,将属性添加到输入元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!