组件:
.component('homeCityListCom',{ bindings: { list: '<', cityname:'&' }, controllerAs: 'vm', template: `按拼音首字母选择` }){{x.sortName}}
控制器:
.controller('cityListCtrl', ['$scope','$http', function ($scope,$http) { let that = this; // 将城市名字存在本地 that.cityName = function(name){ console.log(123); localStorage.setItem('cityName', name); } }])
使用组件:
路由设置:
.state('city_list',{ url:"/city_list", templateUrl:'templates/indexTpl/city_list.html', controllerAs:'cl', controller:'cityListCtrl' })
以上这篇angularjs1.5 组件内用函数向外传值的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。