-1
ngモデルがアドレスを返すような角度のhtmlページがあり、他のhtmlページに同じアドレスを表示したいと思います。どうやってするの?そして、私のコードはモデルの値を別のページに表示する方法
<input type="text" class="form-control" ng-model="Item" placeholder="Enter the IP Address"/>
ngモデルがアドレスを返すような角度のhtmlページがあり、他のhtmlページに同じアドレスを表示したいと思います。どうやってするの?そして、私のコードはモデルの値を別のページに表示する方法
<input type="text" class="form-control" ng-model="Item" placeholder="Enter the IP Address"/>
であるあなたは、このように同様に行うことができます。
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope,$rootScope) {
\t $rootScope.$on('eventName', function(event, args) {
\t \t $scope.emitMessage = args;
});
})
.controller('myCtrl2', function($scope,$rootScope) {
$scope.onclick = function() {
\t $rootScope.$emit('eventName',{msg: 'my message'});
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<div ng-app="myApp">
<div ng-controller="myCtrl">
<p>Message Emitted: {{emitMessage.msg}}</p>
</div>
<div ng-controller="myCtrl2"
<button ng-click="onclick()"> click me to emit message</button>
</div>
</div>
をあなたは、ページ間を移動するには、UI-ルータまたは別のルータを使用していますか?その場合は、モデルを「次のページ」の解決に渡す必要があります。 – rrd
フランクになるにはng route @rrdの使い方は分かりません – venu