@@ -35,16 +35,24 @@ angular.module('material.components.navBar', ['material.core'])
35
35
* https://www.w3.org/TR/wai-aria-practices/#Site_Navigator_Tabbed_Style
36
36
*
37
37
* @param {string= } mdSelectedNavItem The name of the current tab; this must
38
- * match the name attribute of `<md-nav-item>`
38
+ * match the name attribute of `<md-nav-item>`
39
39
* @param {boolean= } mdNoInkBar If set to true, the ink bar will be hidden.
40
40
* @param {string= } navBarAriaLabel An aria-label for the nav-bar
41
41
*
42
42
* @usage
43
43
* <hljs lang="html">
44
44
* <md-nav-bar md-selected-nav-item="currentNavItem">
45
- * <md-nav-item md-nav-click="goto('page1')" name="page1">Page One</md-nav-item>
46
- * <md-nav-item md-nav-sref="app.page2" name="page2">Page Two</md-nav-item>
47
- * <md-nav-item md-nav-href="#page3" name="page3">Page Three</md-nav-item>
45
+ * <md-nav-item md-nav-click="goto('page1')" name="page1">
46
+ * Page One
47
+ * </md-nav-item>
48
+ * <md-nav-item md-nav-href="#page2" name="page3">Page Two</md-nav-item>
49
+ * <md-nav-item md-nav-sref="page3" name="page2">Page Three</md-nav-item>
50
+ * <md-nav-item
51
+ * md-nav-sref="app.page4"
52
+ * sref-opts="{reload: true, notify: true}"
53
+ * name="page4">
54
+ * Page Four
55
+ * </md-nav-item>
48
56
* </md-nav-bar>
49
57
*</hljs>
50
58
* <hljs lang="js">
@@ -72,17 +80,20 @@ angular.module('material.components.navBar', ['material.core'])
72
80
* `<md-nav-item>` describes a page navigation link within the `<md-nav-bar>`
73
81
* component. It renders an md-button as the actual link.
74
82
*
75
- * Exactly one of the mdNavClick, mdNavHref, mdNavSref attributes are required to be
76
- * specified.
83
+ * Exactly one of the mdNavClick, mdNavHref, mdNavSref attributes are required
84
+ * to be specified.
77
85
*
78
86
* @param {Function= } mdNavClick Function which will be called when the
79
- * link is clicked to change the page. Renders as an `ng-click`.
87
+ * link is clicked to change the page. Renders as an `ng-click`.
80
88
* @param {string= } mdNavHref url to transition to when this link is clicked.
81
- * Renders as an `ng-href`.
89
+ * Renders as an `ng-href`.
82
90
* @param {string= } mdNavSref Ui-router state to transition to when this link is
83
- * clicked. Renders as a `ui-sref`.
91
+ * clicked. Renders as a `ui-sref`.
92
+ * @param {!Object= } srefOpts Ui-router options that are passed to the
93
+ * `$state.go()` function. See the [Ui-router documentation for details]
94
+ * (https://ui-router.github.io/docs/latest/interfaces/transition.transitionoptions.html).
84
95
* @param {string= } name The name of this link. Used by the nav bar to know
85
- * which link is currently selected.
96
+ * which link is currently selected.
86
97
*
87
98
* @usage
88
99
* See `<md-nav-bar>` for usage.
@@ -394,7 +405,9 @@ function MdNavItem($$rAF) {
394
405
var hasNavClick = tAttrs . mdNavClick ;
395
406
var hasNavHref = tAttrs . mdNavHref ;
396
407
var hasNavSref = tAttrs . mdNavSref ;
408
+ var hasSrefOpts = tAttrs . srefOpts ;
397
409
var navigationAttribute ;
410
+ var navigationOptions ;
398
411
var buttonTemplate ;
399
412
400
413
// Cannot specify more than one nav attribute
@@ -412,42 +425,49 @@ function MdNavItem($$rAF) {
412
425
} else if ( hasNavSref ) {
413
426
navigationAttribute = 'ui-sref="{{ctrl.mdNavSref}}"' ;
414
427
}
428
+
429
+ navigationOptions = hasSrefOpts ? 'ui-sref-opts="{{ctrl.srefOpts}}" ' : '' ;
415
430
416
431
if ( navigationAttribute ) {
417
432
buttonTemplate = '' +
418
433
'<md-button class="_md-nav-button md-accent" ' +
419
434
'ng-class="ctrl.getNgClassMap()" ' +
420
435
'tabindex="-1" ' +
436
+ navigationOptions +
421
437
navigationAttribute + '>' +
422
438
'<span ng-transclude class="_md-nav-button-text"></span>' +
423
439
'</md-button>' ;
424
440
}
425
441
426
442
return '' +
427
- '<li class="md-nav-item" role="option" aria-selected="{{ctrl.isSelected()}}">' +
443
+ '<li class="md-nav-item" ' +
444
+ 'role="option" ' +
445
+ 'aria-selected="{{ctrl.isSelected()}}">' +
428
446
( buttonTemplate || '' ) +
429
447
'</li>' ;
430
448
} ,
431
449
scope : {
432
450
'mdNavClick' : '&?' ,
433
451
'mdNavHref' : '@?' ,
434
452
'mdNavSref' : '@?' ,
453
+ 'srefOpts' : '=?' ,
435
454
'name' : '@' ,
436
455
} ,
437
456
link : function ( scope , element , attrs , controllers ) {
438
457
var mdNavItem = controllers [ 0 ] ;
439
458
var mdNavBar = controllers [ 1 ] ;
440
459
441
460
// When accessing the element's contents synchronously, they
442
- // may not be defined yet because of transclusion. There is a higher chance
443
- // that it will be accessible if we wait one frame.
461
+ // may not be defined yet because of transclusion. There is a higher
462
+ // chance that it will be accessible if we wait one frame.
444
463
$$rAF ( function ( ) {
445
464
if ( ! mdNavItem . name ) {
446
- mdNavItem . name = angular . element ( element [ 0 ] . querySelector ( '._md-nav-button-text' ) )
447
- . text ( ) . trim ( ) ;
465
+ mdNavItem . name = angular . element ( element [ 0 ]
466
+ . querySelector ( '._md-nav-button-text' ) ) . text ( ) . trim ( ) ;
448
467
}
449
468
450
- var navButton = angular . element ( element [ 0 ] . querySelector ( '._md-nav-button' ) ) ;
469
+ var navButton = angular . element ( element [ 0 ]
470
+ . querySelector ( '._md-nav-button' ) ) ;
451
471
navButton . on ( 'click' , function ( ) {
452
472
mdNavBar . mdSelectedNavItem = mdNavItem . name ;
453
473
scope . $apply ( ) ;
@@ -477,6 +497,10 @@ function MdNavItemController($element) {
477
497
/** @const {?string} */
478
498
this . mdNavHref ;
479
499
500
+ /** @const {?string} */
501
+ this . mdNavSref ;
502
+ /** @const {?Object} */
503
+ this . srefOpts ;
480
504
/** @const {?string} */
481
505
this . name ;
482
506
0 commit comments